Merging upstream version 26.22.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
ecad2ca6a9
commit
3552a78d82
69 changed files with 29194 additions and 28548 deletions
|
@ -331,7 +331,7 @@ class TypeAnnotator(metaclass=_TypeAnnotator):
|
|||
|
||||
if isinstance(type2, exp.DataType):
|
||||
if type2.expressions:
|
||||
return type1
|
||||
return type2
|
||||
type2_value = type2.this
|
||||
else:
|
||||
type2_value = type2
|
||||
|
|
|
@ -100,9 +100,10 @@ def qualify_tables(
|
|||
)
|
||||
|
||||
if pivots:
|
||||
if not pivots[0].alias:
|
||||
pivot_alias = next_alias_name()
|
||||
pivots[0].set("alias", exp.TableAlias(this=exp.to_identifier(pivot_alias)))
|
||||
pivot = pivots[0]
|
||||
if not pivot.alias:
|
||||
pivot_alias = source.alias if pivot.unpivot else next_alias_name()
|
||||
pivot.set("alias", exp.TableAlias(this=exp.to_identifier(pivot_alias)))
|
||||
|
||||
# This case corresponds to a pivoted CTE, we don't want to qualify that
|
||||
if isinstance(scope.sources.get(source.alias_or_name), Scope):
|
||||
|
|
|
@ -39,6 +39,7 @@ class UnsupportedUnit(Exception):
|
|||
def simplify(
|
||||
expression: exp.Expression,
|
||||
constant_propagation: bool = False,
|
||||
coalesce_simplification: bool = False,
|
||||
dialect: DialectType = None,
|
||||
):
|
||||
"""
|
||||
|
@ -53,6 +54,9 @@ def simplify(
|
|||
Args:
|
||||
expression: expression to simplify
|
||||
constant_propagation: whether the constant propagation rule should be used
|
||||
coalesce_simplification: whether the simplify coalesce rule should be used.
|
||||
This rule tries to remove coalesce functions, which can be useful in certain analyses but
|
||||
can leave the query more verbose.
|
||||
Returns:
|
||||
sqlglot.Expression: simplified expression
|
||||
"""
|
||||
|
@ -125,7 +129,9 @@ def simplify(
|
|||
new_node = flatten(new_node)
|
||||
new_node = simplify_connectors(new_node, root)
|
||||
new_node = remove_complements(new_node, root)
|
||||
new_node = simplify_coalesce(new_node, dialect)
|
||||
|
||||
if coalesce_simplification:
|
||||
new_node = simplify_coalesce(new_node, dialect)
|
||||
|
||||
new_node.parent = parent
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue