summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-12-19 11:01:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-12-19 11:01:36 +0000
commit948a422be120c069e48c63a8770fec7204307897 (patch)
tree80bc02d5e6cd3527409386aa1d706272bea54e6c /tests/test_optimizer.py
parentAdding upstream version 20.1.0. (diff)
downloadsqlglot-948a422be120c069e48c63a8770fec7204307897.tar.xz
sqlglot-948a422be120c069e48c63a8770fec7204307897.zip
Adding upstream version 20.3.0.upstream/20.3.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r--tests/test_optimizer.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py
index 141203d..9b68c78 100644
--- a/tests/test_optimizer.py
+++ b/tests/test_optimizer.py
@@ -109,7 +109,9 @@ class TestOptimizer(unittest.TestCase):
},
}
- def check_file(self, file, func, pretty=False, execute=False, set_dialect=False, **kwargs):
+ def check_file(
+ self, file, func, pretty=False, execute=False, set_dialect=False, only=None, **kwargs
+ ):
with ProcessPoolExecutor() as pool:
results = {}
@@ -117,6 +119,8 @@ class TestOptimizer(unittest.TestCase):
load_sql_fixture_pairs(f"optimizer/{file}.sql"), start=1
):
title = meta.get("title") or f"{i}, {sql}"
+ if only and title != only:
+ continue
dialect = meta.get("dialect")
leave_tables_isolated = meta.get("leave_tables_isolated")
@@ -137,13 +141,14 @@ class TestOptimizer(unittest.TestCase):
)
for future in as_completed(results):
- optimized = future.result()
sql, title, expected, dialect, execute = results[future]
with self.subTest(title):
+ optimized = future.result()
+ actual = optimized.sql(pretty=pretty, dialect=dialect)
self.assertEqual(
expected,
- optimized.sql(pretty=pretty, dialect=dialect),
+ actual,
)
if string_to_bool(execute):
@@ -309,7 +314,7 @@ class TestOptimizer(unittest.TestCase):
self.check_file("pushdown_projections", pushdown_projections, schema=self.schema)
def test_simplify(self):
- self.check_file("simplify", simplify)
+ self.check_file("simplify", simplify, set_dialect=True)
expression = parse_one("TRUE AND TRUE AND TRUE")
self.assertEqual(exp.true(), optimizer.simplify.simplify(expression))