summaryrefslogtreecommitdiffstats
path: root/tests/test_build.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-10 11:29:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-10 11:29:05 +0000
commitf818ab3b896d52e874634b7c4db3533078c1887f (patch)
tree8d0f7e4b7f165f33f49da74cb34eb31a0a2d147b /tests/test_build.py
parentReleasing debian version 6.2.8-1. (diff)
downloadsqlglot-f818ab3b896d52e874634b7c4db3533078c1887f.tar.xz
sqlglot-f818ab3b896d52e874634b7c4db3533078c1887f.zip
Merging upstream version 6.3.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_build.py')
-rw-r--r--tests/test_build.py63
1 files changed, 62 insertions, 1 deletions
diff --git a/tests/test_build.py b/tests/test_build.py
index b5d657c..fa9e7f8 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -1,6 +1,19 @@
import unittest
-from sqlglot import and_, condition, exp, from_, not_, or_, parse_one, select
+from sqlglot import (
+ alias,
+ and_,
+ condition,
+ except_,
+ exp,
+ from_,
+ intersect,
+ not_,
+ or_,
+ parse_one,
+ select,
+ union,
+)
class TestBuild(unittest.TestCase):
@@ -320,6 +333,54 @@ class TestBuild(unittest.TestCase):
lambda: exp.update("tbl", {"x": 1}, from_="tbl2"),
"UPDATE tbl SET x = 1 FROM tbl2",
),
+ (
+ lambda: union("SELECT * FROM foo", "SELECT * FROM bla"),
+ "SELECT * FROM foo UNION SELECT * FROM bla",
+ ),
+ (
+ lambda: parse_one("SELECT * FROM foo").union("SELECT * FROM bla"),
+ "SELECT * FROM foo UNION SELECT * FROM bla",
+ ),
+ (
+ lambda: intersect("SELECT * FROM foo", "SELECT * FROM bla"),
+ "SELECT * FROM foo INTERSECT SELECT * FROM bla",
+ ),
+ (
+ lambda: parse_one("SELECT * FROM foo").intersect("SELECT * FROM bla"),
+ "SELECT * FROM foo INTERSECT SELECT * FROM bla",
+ ),
+ (
+ lambda: except_("SELECT * FROM foo", "SELECT * FROM bla"),
+ "SELECT * FROM foo EXCEPT SELECT * FROM bla",
+ ),
+ (
+ lambda: parse_one("SELECT * FROM foo").except_("SELECT * FROM bla"),
+ "SELECT * FROM foo EXCEPT SELECT * FROM bla",
+ ),
+ (
+ lambda: parse_one("(SELECT * FROM foo)").union("SELECT * FROM bla"),
+ "(SELECT * FROM foo) UNION SELECT * FROM bla",
+ ),
+ (
+ lambda: parse_one("(SELECT * FROM foo)").union("SELECT * FROM bla", distinct=False),
+ "(SELECT * FROM foo) UNION ALL SELECT * FROM bla",
+ ),
+ (
+ lambda: alias(parse_one("LAG(x) OVER (PARTITION BY y)"), "a"),
+ "LAG(x) OVER (PARTITION BY y) AS a",
+ ),
+ (
+ lambda: alias(parse_one("LAG(x) OVER (ORDER BY z)"), "a"),
+ "LAG(x) OVER (ORDER BY z) AS a",
+ ),
+ (
+ lambda: alias(parse_one("LAG(x) OVER (PARTITION BY y ORDER BY z)"), "a"),
+ "LAG(x) OVER (PARTITION BY y ORDER BY z) AS a",
+ ),
+ (
+ lambda: alias(parse_one("LAG(x) OVER ()"), "a"),
+ "LAG(x) OVER () AS a",
+ ),
]:
with self.subTest(sql):
self.assertEqual(expression().sql(dialect[0] if dialect else None), sql)