summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-17 10:32:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-17 10:32:12 +0000
commit244a05de60c9417daab9528b51788c3d2a00dc5f (patch)
tree89a9c82aa41d397e1b81c320ad7a287b6c80f313 /tests/test_optimizer.py
parentAdding upstream version 10.4.2. (diff)
downloadsqlglot-244a05de60c9417daab9528b51788c3d2a00dc5f.tar.xz
sqlglot-244a05de60c9417daab9528b51788c3d2a00dc5f.zip
Adding upstream version 10.5.2.upstream/10.5.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r--tests/test_optimizer.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py
index 1c97be7..887f427 100644
--- a/tests/test_optimizer.py
+++ b/tests/test_optimizer.py
@@ -299,10 +299,10 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|')
self.assertEqual(set(scopes[6].sources), {"q", "z", "r", "s"})
self.assertEqual(len(scopes[6].columns), 6)
- self.assertEqual(set(c.table for c in scopes[6].columns), {"r", "s"})
+ self.assertEqual({c.table for c in scopes[6].columns}, {"r", "s"})
self.assertEqual(scopes[6].source_columns("q"), [])
self.assertEqual(len(scopes[6].source_columns("r")), 2)
- self.assertEqual(set(c.table for c in scopes[6].source_columns("r")), {"r"})
+ self.assertEqual({c.table for c in scopes[6].source_columns("r")}, {"r"})
self.assertEqual({c.sql() for c in scopes[-1].find_all(exp.Column)}, {"r.b", "s.b"})
self.assertEqual(scopes[-1].find(exp.Column).sql(), "r.b")
@@ -578,3 +578,16 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|')
scope_t, scope_y = build_scope(query).cte_scopes
self.assertEqual(set(scope_t.cte_sources), {"t"})
self.assertEqual(set(scope_y.cte_sources), {"t", "y"})
+
+ def test_schema_with_spaces(self):
+ schema = {
+ "a": {
+ "b c": "text",
+ '"d e"': "text",
+ }
+ }
+
+ self.assertEqual(
+ optimizer.optimize(parse_one("SELECT * FROM a"), schema=schema),
+ parse_one('SELECT "a"."b c" AS "b c", "a"."d e" AS "d e" FROM "a" AS "a"'),
+ )