summaryrefslogtreecommitdiffstats
path: root/tests/test_transpile.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-26 17:21:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-26 17:21:50 +0000
commit6c774776db5e016d597e582c7006ba8d27006f9d (patch)
tree8a65b7a9938002f9b152d9a6dfd150f15e402a6b /tests/test_transpile.py
parentAdding upstream version 18.13.0. (diff)
downloadsqlglot-6c774776db5e016d597e582c7006ba8d27006f9d.tar.xz
sqlglot-6c774776db5e016d597e582c7006ba8d27006f9d.zip
Adding upstream version 18.17.0.upstream/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)")