diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-11-01 05:12:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-11-01 05:12:38 +0000 |
commit | 613c2506f59fefeb0c0b921ca361c65e99458139 (patch) | |
tree | e1207c41ee9b35d77f1608e87e568fe60d701cf6 /tests/test_optimizer.py | |
parent | Adding upstream version 18.17.0. (diff) | |
download | sqlglot-613c2506f59fefeb0c0b921ca361c65e99458139.tar.xz sqlglot-613c2506f59fefeb0c0b921ca361c65e99458139.zip |
Adding upstream version 19.0.1.upstream/19.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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", + ) |