-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed as not planned
Description
Note: This issue is about optimizer behavior, not dialect-specific parsing/transpilation.
Fully reproducible code snippet (v28.5.0 / main):
import sqlglot
from sqlglot.optimizer.qualify_columns import qualify_columns
sql = 'SELECT * FROM t'
schema = {'t': {'a': 'INT', 'b': 'VARCHAR'}}
parsed = sqlglot.parse_one(sql)
print(f"Star meta: {parsed.expressions[0].meta}")
# {'line': 1, 'col': 8, 'start': 7, 'end': 7}
qualified = qualify_columns(parsed, schema=schema)
for col in qualified.expressions:
print(f"{col}: meta={col.meta}")
# t.a AS a: meta={}
# t.b AS b: meta={}Expected
Expanded columns inherit the star's position metadata.
Actual
Expanded columns have empty meta={}.
References
Expression.update_positions()exists for copying position metadata (used in parser, BigQuery dialect)tests/test_parser.py:985verifies star position metadata is preserved during parsing- Root cause is in
_expand_stars()inqualify_columns.py(line 868), but similar issues exist in the pivot, coalesce (USING), and struct expansion code paths within that function
Happy to submit a PR if this is considered a bug worth fixing. Would appreciate feedback on whether to address just the common case (regular SELECT *) or the other code paths as well.
Metadata
Metadata
Assignees
Labels
No labels