Adding upstream version 23.10.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
27c061b7af
commit
efe1f986ea
91 changed files with 52881 additions and 50396 deletions
|
@ -140,6 +140,26 @@ def remove_precision_parameterized_types(expression: exp.Expression) -> exp.Expr
|
|||
return expression
|
||||
|
||||
|
||||
def unqualify_unnest(expression: exp.Expression) -> exp.Expression:
|
||||
"""Remove references to unnest table aliases, added by the optimizer's qualify_columns step."""
|
||||
from sqlglot.optimizer.scope import find_all_in_scope
|
||||
|
||||
if isinstance(expression, exp.Select):
|
||||
unnest_aliases = {
|
||||
unnest.alias
|
||||
for unnest in find_all_in_scope(expression, exp.Unnest)
|
||||
if isinstance(unnest.parent, (exp.From, exp.Join))
|
||||
}
|
||||
if unnest_aliases:
|
||||
for column in expression.find_all(exp.Column):
|
||||
if column.table in unnest_aliases:
|
||||
column.set("table", None)
|
||||
elif column.db in unnest_aliases:
|
||||
column.set("db", None)
|
||||
|
||||
return expression
|
||||
|
||||
|
||||
def unnest_to_explode(expression: exp.Expression) -> exp.Expression:
|
||||
"""Convert cross join unnest into lateral view explode."""
|
||||
if isinstance(expression, exp.Select):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue