diff options
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r-- | tests/test_optimizer.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py index 8f5dd08..fd95577 100644 --- a/tests/test_optimizer.py +++ b/tests/test_optimizer.py @@ -246,6 +246,15 @@ class TestOptimizer(unittest.TestCase): "CREATE FUNCTION `udfs`.`myTest`(`x` FLOAT64) AS (1)", ) + self.assertEqual( + optimizer.qualify.qualify( + parse_one("SELECT `bar_bazfoo_$id` FROM test", read="spark"), + schema={"test": {"bar_bazFoo_$id": "BIGINT"}}, + dialect="spark", + ).sql(dialect="spark"), + "SELECT `test`.`bar_bazfoo_$id` AS `bar_bazfoo_$id` FROM `test` AS `test`", + ) + self.check_file( "qualify_columns", qualify_columns, execute=True, schema=self.schema, set_dialect=True ) @@ -271,6 +280,8 @@ class TestOptimizer(unittest.TestCase): set_dialect=True, ) + self.assertEqual(optimizer.normalize_identifiers.normalize_identifiers("a%").sql(), '"a%"') + def test_pushdown_projection(self): self.check_file("pushdown_projections", pushdown_projections, schema=self.schema) @@ -978,3 +989,10 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|') query = parse_one("select a.b:c from d", read="snowflake") qualified = optimizer.qualify.qualify(query) self.assertEqual(qualified.expressions[0].alias, "c") + + def test_qualify_tables_no_schema(self): + query = parse_one("select a from b") + self.assertEqual( + optimizer.qualify_tables.qualify_tables(query, catalog="catalog").sql(), + "SELECT a FROM b AS b", + ) |