diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-02 23:59:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-02 23:59:46 +0000 |
commit | 20739a12c39121a9e7ad3c9a2469ec5a6876199d (patch) | |
tree | c000de91c59fd29b2d9beecf9f93b84e69727f37 /tests/test_build.py | |
parent | Releasing debian version 12.2.0-1. (diff) | |
download | sqlglot-20739a12c39121a9e7ad3c9a2469ec5a6876199d.tar.xz sqlglot-20739a12c39121a9e7ad3c9a2469ec5a6876199d.zip |
Merging upstream version 15.0.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_build.py')
-rw-r--r-- | tests/test_build.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/test_build.py b/tests/test_build.py index 509b857..1e28689 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -54,6 +54,8 @@ class TestBuild(unittest.TestCase): (lambda: 1 >= x, "x <= 1"), (lambda: x.eq(1), "x = 1"), (lambda: x.neq(1), "x <> 1"), + (lambda: x.is_(exp.Null()), "x IS NULL"), + (lambda: x.as_("y"), "x AS y"), (lambda: x.isin(1, "2"), "x IN (1, '2')"), (lambda: x.isin(query="select 1"), "x IN (SELECT 1)"), (lambda: x.between(1, 2), "x BETWEEN 1 AND 2"), @@ -86,13 +88,8 @@ class TestBuild(unittest.TestCase): lambda: select("x").select("y", append=False).from_("tbl"), "SELECT y FROM tbl", ), - (lambda: select("x").from_("tbl").from_("tbl2"), "SELECT x FROM tbl, tbl2"), ( - lambda: select("x").from_("tbl, tbl2", "tbl3").from_("tbl4"), - "SELECT x FROM tbl, tbl2, tbl3, tbl4", - ), - ( - lambda: select("x").from_("tbl").from_("tbl2", append=False), + lambda: select("x").from_("tbl").from_("tbl2"), "SELECT x FROM tbl2", ), (lambda: select("SUM(x) AS y"), "SELECT SUM(x) AS y"), @@ -285,10 +282,12 @@ class TestBuild(unittest.TestCase): ( lambda: select("x").from_("tbl").cluster_by("y"), "SELECT x FROM tbl CLUSTER BY y", + "hive", ), ( lambda: select("x").from_("tbl").sort_by("y"), "SELECT x FROM tbl SORT BY y", + "hive", ), ( lambda: select("x").from_("tbl").order_by("x, y DESC"), @@ -297,10 +296,12 @@ class TestBuild(unittest.TestCase): ( lambda: select("x").from_("tbl").cluster_by("x, y DESC"), "SELECT x FROM tbl CLUSTER BY x, y DESC", + "hive", ), ( lambda: select("x").from_("tbl").sort_by("x, y DESC"), "SELECT x FROM tbl SORT BY x, y DESC", + "hive", ), ( lambda: select("x", "y", "z", "a").from_("tbl").order_by("x, y", "z").order_by("a"), @@ -312,10 +313,12 @@ class TestBuild(unittest.TestCase): .cluster_by("x, y", "z") .cluster_by("a"), "SELECT x, y, z, a FROM tbl CLUSTER BY x, y, z, a", + "hive", ), ( lambda: select("x", "y", "z", "a").from_("tbl").sort_by("x, y", "z").sort_by("a"), "SELECT x, y, z, a FROM tbl SORT BY x, y, z, a", + "hive", ), (lambda: select("x").from_("tbl").limit(10), "SELECT x FROM tbl LIMIT 10"), ( @@ -393,7 +396,7 @@ class TestBuild(unittest.TestCase): .with_("tbl", as_=select("x").from_("tbl2")) .from_("tbl") .join("tbl3"), - "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl JOIN tbl3", + "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl, tbl3", ), ( lambda: select("x") @@ -594,6 +597,22 @@ class TestBuild(unittest.TestCase): "postgres", ), ( + lambda: exp.insert("SELECT * FROM tbl2", "tbl"), + "INSERT INTO tbl SELECT * FROM tbl2", + ), + ( + lambda: exp.insert("SELECT * FROM tbl2", "tbl", overwrite=True), + "INSERT OVERWRITE TABLE tbl SELECT * FROM tbl2", + ), + ( + lambda: exp.insert("VALUES (1, 2), (3, 4)", "tbl", columns=["cola", "colb"]), + "INSERT INTO tbl (cola, colb) VALUES (1, 2), (3, 4)", + ), + ( + lambda: exp.insert("SELECT * FROM cte", "t").with_("cte", as_="SELECT x FROM tbl"), + "WITH cte AS (SELECT x FROM tbl) INSERT INTO t SELECT * FROM cte", + ), + ( lambda: exp.convert((exp.column("x"), exp.column("y"))).isin((1, 2), (3, 4)), "(x, y) IN ((1, 2), (3, 4))", "postgres", |