summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:13 +0000
commitcdffd0b29d5b072639bb02118d6828f4d1b76099 (patch)
tree57ec0b75c40e40a33060b63599bbba6f0af27ae8 /tests/test_optimizer.py
parentAdding upstream version 17.11.0. (diff)
downloadsqlglot-cdffd0b29d5b072639bb02118d6828f4d1b76099.tar.xz
sqlglot-cdffd0b29d5b072639bb02118d6828f4d1b76099.zip
Adding upstream version 17.12.0.upstream/17.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/test_optimizer.py14
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",