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.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py
index e7588b5..7735e78 100644
--- a/tests/test_expressions.py
+++ b/tests/test_expressions.py
@@ -147,8 +147,8 @@ class TestExpressions(unittest.TestCase):
["a", "B", "e", "*", "zz", "z"],
)
self.assertEqual(
- [e.alias_or_name for e in expression.args["from"].expressions],
- ["bar", "baz"],
+ {e.alias_or_name for e in expression.find_all(exp.Table)},
+ {"bar", "baz"},
)
expression = parse_one(
@@ -164,9 +164,10 @@ class TestExpressions(unittest.TestCase):
["first", "second"],
)
+ self.assertEqual("first", expression.args["from"].alias_or_name)
self.assertEqual(
- [e.alias_or_name for e in expression.args["from"].expressions],
- ["first", "second", "third"],
+ [e.alias_or_name for e in expression.args["joins"]],
+ ["second", "third"],
)
self.assertEqual(parse_one("x.*").name, "*")
@@ -185,10 +186,10 @@ class TestExpressions(unittest.TestCase):
def test_replace_tables(self):
self.assertEqual(
exp.replace_tables(
- parse_one("select * from a AS a join b join c.a join d.a join e.a"),
+ parse_one("select * from a AS a, b, c.a, d.a cross join e.a"),
{"a": "a1", "b": "b.a", "c.a": "c.a2", "d.a": "d2"},
).sql(),
- "SELECT * FROM a1 AS a JOIN b.a JOIN c.a2 JOIN d2 JOIN e.a",
+ "SELECT * FROM a1 AS a, b.a, c.a2, d2 CROSS JOIN e.a",
)
def test_replace_placeholders(self):
@@ -532,6 +533,7 @@ class TestExpressions(unittest.TestCase):
self.assertIsInstance(parse_one("YEAR(a)"), exp.Year)
self.assertIsInstance(parse_one("HLL(a)"), exp.Hll)
self.assertIsInstance(parse_one("ARRAY(time, foo)"), exp.Array)
+ self.assertIsInstance(parse_one("STANDARD_HASH('hello', 'sha256')"), exp.StandardHash)
def test_column(self):
column = parse_one("a.b.c.d")
@@ -610,7 +612,6 @@ class TestExpressions(unittest.TestCase):
"FORMAT": "parquet",
"PARTITIONED_BY": (exp.to_identifier("a"), exp.to_identifier("b")),
"custom": 1,
- "TABLE_FORMAT": exp.to_identifier("test_format"),
"ENGINE": None,
"COLLATE": True,
}
@@ -622,7 +623,6 @@ class TestExpressions(unittest.TestCase):
this=exp.Tuple(expressions=[exp.to_identifier("a"), exp.to_identifier("b")])
),
exp.Property(this=exp.Literal.string("custom"), value=exp.Literal.number(1)),
- exp.TableFormatProperty(this=exp.to_identifier("test_format")),
exp.EngineProperty(this=exp.null()),
exp.CollateProperty(this=exp.true()),
]
@@ -726,10 +726,6 @@ FROM foo""",
self.assertEqual(catalog_db_and_table.args.get("catalog"), exp.to_identifier("catalog"))
with self.assertRaises(ValueError):
exp.to_table(1)
- empty_string = exp.to_table("")
- self.assertEqual(empty_string.name, "")
- self.assertIsNone(table_only.args.get("db"))
- self.assertIsNone(table_only.args.get("catalog"))
def test_to_column(self):
column_only = exp.to_column("column_name")