summaryrefslogtreecommitdiffstats
path: root/tests/test_transpile.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-26 17:21:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-26 17:21:54 +0000
commitc03ba18c491e52cc85d8aae1825dd9e0b4f75e32 (patch)
treef76d58b50900be4bfd2dc15f0ec38d1a70d8417b /tests/test_transpile.py
parentReleasing debian version 18.13.0-1. (diff)
downloadsqlglot-c03ba18c491e52cc85d8aae1825dd9e0b4f75e32.tar.xz
sqlglot-c03ba18c491e52cc85d8aae1825dd9e0b4f75e32.zip
Merging upstream version 18.17.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_transpile.py')
-rw-r--r--tests/test_transpile.py57
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/test_transpile.py b/tests/test_transpile.py
index d588f07..c16b1f6 100644
--- a/tests/test_transpile.py
+++ b/tests/test_transpile.py
@@ -19,6 +19,9 @@ class TestTranspile(unittest.TestCase):
def validate(self, sql, target, **kwargs):
self.assertEqual(transpile(sql, **kwargs)[0], target)
+ def test_weird_chars(self):
+ self.assertEqual(transpile("0Êß")[0], "0 AS Êß")
+
def test_alias(self):
self.assertEqual(transpile("SELECT SUM(y) KEEP")[0], "SELECT SUM(y) AS KEEP")
self.assertEqual(transpile("SELECT 1 overwrite")[0], "SELECT 1 AS overwrite")
@@ -87,7 +90,18 @@ class TestTranspile(unittest.TestCase):
self.validate("SELECT 3>=3", "SELECT 3 >= 3")
def test_comments(self):
- self.validate("SELECT\n foo\n/* comments */\n;", "SELECT foo /* comments */")
+ self.validate(
+ "SELECT * FROM t1\n/*x*/\nUNION ALL SELECT * FROM t2",
+ "SELECT * FROM t1 /* x */ UNION ALL SELECT * FROM t2",
+ )
+ self.validate(
+ "SELECT * FROM t1\n/*x*/\nINTERSECT ALL SELECT * FROM t2",
+ "SELECT * FROM t1 /* x */ INTERSECT ALL SELECT * FROM t2",
+ )
+ self.validate(
+ "SELECT\n foo\n/* comments */\n;",
+ "SELECT foo /* comments */",
+ )
self.validate(
"SELECT * FROM a INNER /* comments */ JOIN b",
"SELECT * FROM a /* comments */ INNER JOIN b",
@@ -379,6 +393,47 @@ LEFT OUTER JOIN b""",
FROM tbl""",
pretty=True,
)
+ self.validate(
+ """
+SELECT
+ 'hotel1' AS hotel,
+ *
+FROM dw_1_dw_1_1.exactonline_1.transactionlines
+/*
+ UNION ALL
+ SELECT
+ 'Thon Partner Hotel Jølster' AS hotel,
+ name,
+ date,
+ CAST(identifier AS VARCHAR) AS identifier,
+ value
+ FROM d2o_889_oupjr_1348.public.accountvalues_forecast
+*/
+UNION ALL
+SELECT
+ 'hotel2' AS hotel,
+ *
+FROM dw_1_dw_1_1.exactonline_2.transactionlines""",
+ """SELECT
+ 'hotel1' AS hotel,
+ *
+FROM dw_1_dw_1_1.exactonline_1.transactionlines /*
+ UNION ALL
+ SELECT
+ 'Thon Partner Hotel Jølster' AS hotel,
+ name,
+ date,
+ CAST(identifier AS VARCHAR) AS identifier,
+ value
+ FROM d2o_889_oupjr_1348.public.accountvalues_forecast
+*/
+UNION ALL
+SELECT
+ 'hotel2' AS hotel,
+ *
+FROM dw_1_dw_1_1.exactonline_2.transactionlines""",
+ pretty=True,
+ )
def test_types(self):
self.validate("INT 1", "CAST(1 AS INT)")