diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-14 10:12:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-14 10:12:19 +0000 |
commit | 3742f86d166160ca3843872ebecb6f30c51f6085 (patch) | |
tree | 6d747c3e7082fc2bae56053930813d5625e9b3d8 /tests/test_optimizer.py | |
parent | Releasing debian version 17.11.0-1. (diff) | |
download | sqlglot-3742f86d166160ca3843872ebecb6f30c51f6085.tar.xz sqlglot-3742f86d166160ca3843872ebecb6f30c51f6085.zip |
Merging upstream version 17.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r-- | tests/test_optimizer.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py index 3fe53e4..a1bd309 100644 --- a/tests/test_optimizer.py +++ b/tests/test_optimizer.py @@ -277,6 +277,20 @@ class TestOptimizer(unittest.TestCase): self.assertEqual(exp.true(), optimizer.simplify.simplify(expression)) self.assertEqual(exp.true(), optimizer.simplify.simplify(expression.this)) + # CONCAT in (e.g.) Presto is parsed as Concat instead of SafeConcat which is the default type + # This test checks that simplify_concat preserves the corresponding expression types. + concat = parse_one("CONCAT('a', x, 'b', 'c')", read="presto") + simplified_concat = optimizer.simplify.simplify(concat) + + safe_concat = parse_one("CONCAT('a', x, 'b', 'c')") + simplified_safe_concat = optimizer.simplify.simplify(safe_concat) + + self.assertIs(type(simplified_concat), exp.Concat) + self.assertIs(type(simplified_safe_concat), exp.SafeConcat) + + self.assertEqual("CONCAT('a', x, 'bc')", simplified_concat.sql(dialect="presto")) + self.assertEqual("CONCAT('a', x, 'bc')", simplified_safe_concat.sql()) + def test_unnest_subqueries(self): self.check_file( "unnest_subqueries", |