You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Follow-up to #352: UNNEST(...) alias, alias.field still reported as a table #689
h is bound by the UNNEST and never appears in tables_aliases, so a consumer cannot tell a table from a flattened field. This is the standard BigQuery ga_sessions shape.
Thanks for the clear repro — I can confirm this on current master. The root cause is that sqlglot parses a later alias.field reference (e.g. h.customDimensions after UNNEST(t.hits) h) as an exp.Table node with db=h, so TableExtractor emits h.customDimensions as a table name and the UNNEST alias h is never tracked.
I've opened #702 with a minimal fix: TableExtractor now collects the aliases introduced by exp.Unnest nodes (both TableAlias.this for UNNEST(x) AS a and TableAlias.columns for UNNEST(x) a) and drops any table whose catalog/db segment matches one of them. The reported query now yields tables == ['proj.ds.ga_sessions_*'] and tables_aliases == {'t': 'proj.ds.ga_sessions_*'}.
A regression test is included; pytest test/ is 277 passed with 100% coverage, mypy and ruff check are clean. Happy to adjust if you'd prefer a different approach.
Activity
Yuren0312 commentedon Oct 18, 2026
Thanks for the clear repro — I can confirm this on current master. The root cause is that sqlglot parses a later
alias.fieldreference (e.g.h.customDimensionsafterUNNEST(t.hits) h) as anexp.Tablenode withdb=h, soTableExtractoremitsh.customDimensionsas a table name and the UNNEST aliashis never tracked.I've opened #702 with a minimal fix:
TableExtractornow collects the aliases introduced byexp.Unnestnodes (bothTableAlias.thisforUNNEST(x) AS aandTableAlias.columnsforUNNEST(x) a) and drops any table whose catalog/db segment matches one of them. The reported query now yieldstables == ['proj.ds.ga_sessions_*']andtables_aliases == {'t': 'proj.ds.ga_sessions_*'}.A regression test is included;
pytest test/is 277 passed with 100% coverage,mypyandruff checkare clean. Happy to adjust if you'd prefer a different approach.