Merging upstream version 26.8.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
d551ab0954
commit
010433ad9a
61 changed files with 43883 additions and 41898 deletions
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from sqlglot import parse_one
|
||||
from sqlglot import parse_one, expressions as exp
|
||||
from sqlglot.transforms import (
|
||||
eliminate_distinct_on,
|
||||
eliminate_join_marks,
|
||||
|
@ -147,7 +147,7 @@ class TestTransforms(unittest.TestCase):
|
|||
self.validate(
|
||||
eliminate_qualify,
|
||||
"SELECT x AS z FROM y QUALIFY ROW_NUMBER() OVER (PARTITION BY z)",
|
||||
"SELECT z FROM (SELECT x AS z, ROW_NUMBER() OVER (PARTITION BY x) AS _w, x FROM y) AS _t WHERE _w",
|
||||
"SELECT z FROM (SELECT x AS z, ROW_NUMBER() OVER (PARTITION BY x) AS _w FROM y) AS _t WHERE _w",
|
||||
)
|
||||
self.validate(
|
||||
eliminate_qualify,
|
||||
|
@ -162,7 +162,12 @@ class TestTransforms(unittest.TestCase):
|
|||
self.validate(
|
||||
eliminate_qualify,
|
||||
"SELECT y.x AS x, y.t AS z FROM y QUALIFY ROW_NUMBER() OVER (PARTITION BY x ORDER BY x DESC, z)",
|
||||
"SELECT x, z FROM (SELECT y.x AS x, y.t AS z, ROW_NUMBER() OVER (PARTITION BY y.x ORDER BY y.x DESC, y.t) AS _w, y.t FROM y) AS _t WHERE _w",
|
||||
"SELECT x, z FROM (SELECT y.x AS x, y.t AS z, ROW_NUMBER() OVER (PARTITION BY y.x ORDER BY y.x DESC, y.t) AS _w FROM y) AS _t WHERE _w",
|
||||
)
|
||||
self.validate(
|
||||
eliminate_qualify,
|
||||
"select max(col) over (partition by col_id) as col, from some_table qualify row_number() over (partition by col_id order by col asc)=1",
|
||||
"SELECT col FROM (SELECT MAX(col) OVER (PARTITION BY col_id) AS col, ROW_NUMBER() OVER (PARTITION BY col_id ORDER BY MAX(col) OVER (PARTITION BY col_id) ASC) AS _w, col_id FROM some_table) AS _t WHERE _w = 1",
|
||||
)
|
||||
|
||||
def test_remove_precision_parameterized_types(self):
|
||||
|
@ -251,3 +256,12 @@ class TestTransforms(unittest.TestCase):
|
|||
f"SELECT table1.id, table2.cloumn1, table3.id FROM table1 LEFT JOIN table2 ON table1.id = table2.id LEFT JOIN (SELECT tableInner1.id FROM tableInner1 LEFT JOIN tableInner2 ON tableInner1.id = tableInner2.id) {alias}table3 ON table1.id = table3.id",
|
||||
dialect,
|
||||
)
|
||||
|
||||
# if multiple conditions, we check that after transformations the tree remains consistent
|
||||
s = "select a.id from a, b where a.id = b.id (+) AND b.d (+) = const"
|
||||
tree = eliminate_join_marks(parse_one(s, dialect=dialect))
|
||||
assert all(type(t.parent_select) is exp.Select for t in tree.find_all(exp.Table))
|
||||
assert (
|
||||
tree.sql(dialect=dialect)
|
||||
== "SELECT a.id FROM a LEFT JOIN b ON a.id = b.id AND b.d = const"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue