1
0
Fork 0

Adding upstream version 12.2.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 15:52:54 +01:00
parent 82a8846a46
commit 70d5d3451a
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
100 changed files with 35022 additions and 30936 deletions

View file

@ -47,6 +47,7 @@ class TestOptimizer(unittest.TestCase):
@classmethod
def setUpClass(cls):
sqlglot.schema = MappingSchema()
cls.conn = duckdb.connect()
cls.conn.execute(
"""
@ -221,6 +222,12 @@ class TestOptimizer(unittest.TestCase):
self.check_file("pushdown_predicates", optimizer.pushdown_predicates.pushdown_predicates)
def test_expand_laterals(self):
# check order of lateral expansion with no schema
self.assertEqual(
optimizer.optimize("SELECT a + 1 AS d, d + 1 AS e FROM x " "").sql(),
'SELECT "x"."a" + 1 AS "d", "x"."a" + 2 AS "e" FROM "x" AS "x"',
)
self.check_file(
"expand_laterals",
optimizer.expand_laterals.expand_laterals,
@ -612,6 +619,12 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|')
expression = annotate_types(parse_one("CONCAT('A', 'B')"))
self.assertEqual(expression.type.this, exp.DataType.Type.VARCHAR)
def test_root_subquery_annotation(self):
expression = annotate_types(parse_one("(SELECT 1, 2 FROM x) LIMIT 0"))
self.assertIsInstance(expression, exp.Subquery)
self.assertEqual(exp.DataType.Type.INT, expression.selects[0].type.this)
self.assertEqual(exp.DataType.Type.INT, expression.selects[1].type.this)
def test_recursive_cte(self):
query = parse_one(
"""