summaryrefslogtreecommitdiffstats
path: root/tests/test_expressions.py
diff options
context:
space:
mode:
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")