summaryrefslogtreecommitdiffstats
path: root/tests/test_expressions.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-03-19 10:22:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-03-19 10:22:04 +0000
commit57c3067868d0a1da90ec0f2201dd91f031241274 (patch)
tree3b16819683e27ccbc7e7726675ab8d3e978fc8aa /tests/test_expressions.py
parentAdding upstream version 11.3.6. (diff)
downloadsqlglot-57c3067868d0a1da90ec0f2201dd91f031241274.tar.xz
sqlglot-57c3067868d0a1da90ec0f2201dd91f031241274.zip
Adding upstream version 11.4.1.upstream/11.4.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r--tests/test_expressions.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py
index ecbdc24..69e1d14 100644
--- a/tests/test_expressions.py
+++ b/tests/test_expressions.py
@@ -6,6 +6,8 @@ from sqlglot import alias, exp, parse_one
class TestExpressions(unittest.TestCase):
+ maxDiff = None
+
def test_arg_key(self):
self.assertEqual(parse_one("sum(1)").find(exp.Literal).arg_key, "this")
@@ -91,6 +93,32 @@ class TestExpressions(unittest.TestCase):
self.assertIsInstance(column.parent_select, exp.Select)
self.assertIsNone(column.find_ancestor(exp.Join))
+ def test_to_dot(self):
+ column = parse_one('a.b.c."d".e.f').find(exp.Column)
+ dot = column.to_dot()
+
+ self.assertEqual(dot.sql(), 'a.b.c."d".e.f')
+
+ self.assertEqual(
+ dot,
+ exp.Dot(
+ this=exp.Dot(
+ this=exp.Dot(
+ this=exp.Dot(
+ this=exp.Dot(
+ this=exp.to_identifier("a"),
+ expression=exp.to_identifier("b"),
+ ),
+ expression=exp.to_identifier("c"),
+ ),
+ expression=exp.to_identifier("d", quoted=True),
+ ),
+ expression=exp.to_identifier("e"),
+ ),
+ expression=exp.to_identifier("f"),
+ ),
+ )
+
def test_root(self):
ast = parse_one("select * from (select a from x)")
self.assertIs(ast, ast.root())
@@ -480,6 +508,7 @@ class TestExpressions(unittest.TestCase):
self.assertIsInstance(parse_one("COMMIT"), exp.Commit)
self.assertIsInstance(parse_one("ROLLBACK"), exp.Rollback)
self.assertIsInstance(parse_one("GENERATE_SERIES(a, b, c)"), exp.GenerateSeries)
+ self.assertIsInstance(parse_one("COUNT_IF(a > 0)"), exp.CountIf)
def test_column(self):
column = parse_one("a.b.c.d")