1
0
Fork 0

Merging upstream version 26.2.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 22:00:08 +01:00
parent a5399bd16b
commit 4d0635d636
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
85 changed files with 57142 additions and 52288 deletions

View file

@ -146,9 +146,7 @@ class Scope:
self._udtfs.append(node)
elif isinstance(node, exp.CTE):
self._ctes.append(node)
elif _is_derived_table(node) and isinstance(
node.parent, (exp.From, exp.Join, exp.Subquery)
):
elif _is_derived_table(node) and _is_from_or_join(node):
self._derived_tables.append(node)
elif isinstance(node, exp.UNWRAPPED_QUERIES):
self._subqueries.append(node)
@ -661,6 +659,19 @@ def _is_derived_table(expression: exp.Subquery) -> bool:
)
def _is_from_or_join(expression: exp.Expression) -> bool:
"""
Determine if `expression` is the FROM or JOIN clause of a SELECT statement.
"""
parent = expression.parent
# Subqueries can be arbitrarily nested
while isinstance(parent, exp.Subquery):
parent = parent.parent
return isinstance(parent, (exp.From, exp.Join))
def _traverse_tables(scope):
sources = {}