summaryrefslogtreecommitdiffstats
path: root/tests/test_expressions.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-04-07 12:35:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-04-07 12:35:04 +0000
commitfb7e79eb4c8d6e22b7324de4bb1ea9cd11b8da7c (patch)
tree476513580a6824dfe34364f98f0dbf7f66d188f4 /tests/test_expressions.py
parentReleasing debian version 11.4.5-1. (diff)
downloadsqlglot-fb7e79eb4c8d6e22b7324de4bb1ea9cd11b8da7c.tar.xz
sqlglot-fb7e79eb4c8d6e22b7324de4bb1ea9cd11b8da7c.zip
Merging upstream version 11.5.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r--tests/test_expressions.py40
1 files changed, 21 insertions, 19 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py
index c22f13e..b09b2ab 100644
--- a/tests/test_expressions.py
+++ b/tests/test_expressions.py
@@ -194,30 +194,31 @@ class TestExpressions(unittest.TestCase):
def test_replace_placeholders(self):
self.assertEqual(
exp.replace_placeholders(
- parse_one("select * from :tbl1 JOIN :tbl2 ON :col1 = :col2 WHERE :col3 > 100"),
- tbl1="foo",
- tbl2="bar",
- col1="a",
- col2="b",
- col3="c",
+ parse_one("select * from :tbl1 JOIN :tbl2 ON :col1 = :str1 WHERE :col2 > :int1"),
+ tbl1=exp.to_identifier("foo"),
+ tbl2=exp.to_identifier("bar"),
+ col1=exp.to_identifier("a"),
+ col2=exp.to_identifier("c"),
+ str1="b",
+ int1=100,
).sql(),
- "SELECT * FROM foo JOIN bar ON a = b WHERE c > 100",
+ "SELECT * FROM foo JOIN bar ON a = 'b' WHERE c > 100",
)
self.assertEqual(
exp.replace_placeholders(
- parse_one("select * from ? JOIN ? ON ? = ? WHERE ? > 100"),
- "foo",
- "bar",
- "a",
+ parse_one("select * from ? JOIN ? ON ? = ? WHERE ? = 'bla'"),
+ exp.to_identifier("foo"),
+ exp.to_identifier("bar"),
+ exp.to_identifier("a"),
"b",
- "c",
+ "bla",
).sql(),
- "SELECT * FROM foo JOIN bar ON a = b WHERE c > 100",
+ "SELECT * FROM foo JOIN bar ON a = 'b' WHERE 'bla' = 'bla'",
)
self.assertEqual(
exp.replace_placeholders(
parse_one("select * from ? WHERE ? > 100"),
- "foo",
+ exp.to_identifier("foo"),
).sql(),
"SELECT * FROM foo WHERE ? > 100",
)
@@ -229,12 +230,12 @@ class TestExpressions(unittest.TestCase):
)
self.assertEqual(
exp.replace_placeholders(
- parse_one("select * from (SELECT :col1 FROM ?) WHERE :col2 > 100"),
- "tbl1",
- "tbl2",
+ parse_one("select * from (SELECT :col1 FROM ?) WHERE :col2 > ?"),
+ exp.to_identifier("tbl1"),
+ 100,
"tbl3",
- col1="a",
- col2="b",
+ col1=exp.to_identifier("a"),
+ col2=exp.to_identifier("b"),
col3="c",
).sql(),
"SELECT * FROM (SELECT a FROM tbl1) WHERE b > 100",
@@ -526,6 +527,7 @@ class TestExpressions(unittest.TestCase):
self.assertIsInstance(parse_one("VARIANCE(a)"), exp.Variance)
self.assertIsInstance(parse_one("VARIANCE_POP(a)"), exp.VariancePop)
self.assertIsInstance(parse_one("YEAR(a)"), exp.Year)
+ self.assertIsInstance(parse_one("HLL(a)"), exp.Hll)
def test_column(self):
column = parse_one("a.b.c.d")