Skip to content

Do not report the ALL of LIMIT ALL as a column - #727

Open
zzoraemon043 wants to merge 1 commit into
macbre:masterfrom
zzoraemon043:fix/limit-all-column
Open

zzoraemon043 wants to merge 1 commit into
macbre:masterfrom
zzoraemon043:fix/limit-all-column

Conversation

@zzoraemon043

Copy link
Copy Markdown

LIMIT ALL is reported as a column:

>>> Parser("SELECT a FROM t ORDER BY a LIMIT ALL").columns
['a', 'ALL']

Outside the PostgreSQL dialect sqlglot parses LIMIT ALL as a Limit whose expression is Column(ALL) (Postgres gives Var(ALL)), and the column extractor picks it up. The same happens inside CTEs and subqueries.

This skips an unquoted, unqualified ALL column whose parent is a Limit node, both in the main walk and in _flat_columns. A quoted "all" column elsewhere is unaffected.

Tests: two cases in test_getting_columns.py; test_limit_all_is_not_a_column fails on master. Full suite 294 passed, coverage 100%, mypy clean.

Outside the PostgreSQL dialect sqlglot parses LIMIT ALL as a Limit
whose expression is a Column named ALL, so Parser.columns returned
['a', 'ALL'] for SELECT a FROM t LIMIT ALL. Skip an unquoted,
unqualified ALL column directly under a Limit node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant