summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_hive.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-19 13:44:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-19 13:44:59 +0000
commitef2db38de92f2329c1c366318bddfc7e3dee8415 (patch)
treedee41de1eb0e05f2f6805b77df41a71b3aa66ec2 /tests/dialects/test_hive.py
parentAdding upstream version 11.0.1. (diff)
downloadsqlglot-ef2db38de92f2329c1c366318bddfc7e3dee8415.tar.xz
sqlglot-ef2db38de92f2329c1c366318bddfc7e3dee8415.zip
Adding upstream version 11.1.3.upstream/11.1.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_hive.py')
-rw-r--r--tests/dialects/test_hive.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/tests/dialects/test_hive.py b/tests/dialects/test_hive.py
index 42d9943..a067764 100644
--- a/tests/dialects/test_hive.py
+++ b/tests/dialects/test_hive.py
@@ -214,11 +214,11 @@ class TestHive(Validator):
self.validate_all(
"'\\\\a'",
read={
- "presto": "'\\a'",
+ "presto": "'\\\\a'",
},
write={
- "duckdb": "'\\a'",
- "presto": "'\\a'",
+ "duckdb": "'\\\\a'",
+ "presto": "'\\\\a'",
"hive": "'\\\\a'",
"spark": "'\\\\a'",
},
@@ -345,13 +345,13 @@ class TestHive(Validator):
"INSERT OVERWRITE TABLE zipcodes PARTITION(state = 0) VALUES (896, 'US', 'TAMPA', 33607)"
)
self.validate_identity(
- "SELECT a, b, SUM(c) FROM tabl AS t GROUP BY a, b GROUPING SETS ((a, b), a)"
+ "SELECT a, b, SUM(c) FROM tabl AS t GROUP BY a, b, GROUPING SETS ((a, b), a)"
)
self.validate_identity(
- "SELECT a, b, SUM(c) FROM tabl AS t GROUP BY a, b GROUPING SETS ((t.a, b), a)"
+ "SELECT a, b, SUM(c) FROM tabl AS t GROUP BY a, b, GROUPING SETS ((t.a, b), a)"
)
self.validate_identity(
- "SELECT a, b, SUM(c) FROM tabl AS t GROUP BY a, FOO(b) GROUPING SETS ((a, FOO(b)), a)"
+ "SELECT a, b, SUM(c) FROM tabl AS t GROUP BY a, FOO(b), GROUPING SETS ((a, FOO(b)), a)"
)
self.validate_identity(
"SELECT key, value, GROUPING__ID, COUNT(*) FROM T1 GROUP BY key, value WITH CUBE"
@@ -648,8 +648,20 @@ class TestHive(Validator):
},
)
self.validate_all(
- "SELECT a, SUM(c) FROM t GROUP BY a, DATE_FORMAT(b, 'yyyy') GROUPING SETS ((a, DATE_FORMAT(b, 'yyyy')), a)",
+ "SELECT a, SUM(c) FROM t GROUP BY a, DATE_FORMAT(b, 'yyyy'), GROUPING SETS ((a, DATE_FORMAT(b, 'yyyy')), a)",
write={
- "hive": "SELECT a, SUM(c) FROM t GROUP BY a, DATE_FORMAT(CAST(b AS TIMESTAMP), 'yyyy') GROUPING SETS ((a, DATE_FORMAT(CAST(b AS TIMESTAMP), 'yyyy')), a)",
+ "hive": "SELECT a, SUM(c) FROM t GROUP BY a, DATE_FORMAT(CAST(b AS TIMESTAMP), 'yyyy'), GROUPING SETS ((a, DATE_FORMAT(CAST(b AS TIMESTAMP), 'yyyy')), a)",
},
)
+
+ def test_escapes(self) -> None:
+ self.validate_identity("'\n'")
+ self.validate_identity("'\\n'")
+ self.validate_identity("'\\\n'")
+ self.validate_identity("'\\\\n'")
+ self.validate_identity("''")
+ self.validate_identity("'\\\\'")
+ self.validate_identity("'\z'")
+ self.validate_identity("'\\z'")
+ self.validate_identity("'\\\z'")
+ self.validate_identity("'\\\\z'")