summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/bigquery.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglot/dialects/bigquery.py')
-rw-r--r--sqlglot/dialects/bigquery.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/sqlglot/dialects/bigquery.py b/sqlglot/dialects/bigquery.py
index 8786063..c9d6c79 100644
--- a/sqlglot/dialects/bigquery.py
+++ b/sqlglot/dialects/bigquery.py
@@ -96,13 +96,14 @@ def _unqualify_unnest(expression: exp.Expression) -> exp.Expression:
These are added by the optimizer's qualify_column step.
"""
+ from sqlglot.optimizer.scope import Scope
+
if isinstance(expression, exp.Select):
for unnest in expression.find_all(exp.Unnest):
if isinstance(unnest.parent, (exp.From, exp.Join)) and unnest.alias:
- for select in expression.selects:
- for column in select.find_all(exp.Column):
- if column.table == unnest.alias:
- column.set("table", None)
+ for column in Scope(expression).find_all(exp.Column):
+ if column.table == unnest.alias:
+ column.set("table", None)
return expression