Skip to content

fix: point and word the playground's common syntax and alias errors clearly - #181

Merged
kvlonge merged 4 commits into
mainfrom
fix/snowflake-clause-keyword-columns
Nov 11, 2026
Merged

kvlonge merged 4 commits into
mainfrom
fix/snowflake-clause-keyword-columns

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Why

The playground's first impressions had three rough edges:

  • The "Syntax error" example, a condition left open before GROUP BY, put its error one token late, at BY.
  • A statement ending where an expression belongs, such as an empty WHERE, said "Unexpected token: Where".
  • An unaliased column's SQ0009 label named an internal node kind (j_s_o_n_extract). Its help guessed a wrong alias for paths ("PAYLOAD" for payload:page) and a quoted copy for literals.

Changes

One commit each:

  • GROUP or ORDER directly before BY always starts the clause and is never read as a name, so the error points at GROUP or ORDER.
  • A statement that ends where an expression belongs says what is missing: a condition after WHERE, HAVING, QUALIFY or ON, otherwise an expression.
  • The SQ0009 label reads "Snowflake names this column after its text". A literal or path says its quotes or path are part of the name, and its help asks for an alias without guessing one. Statements are still refused.

Verification

  • The GROUP BY span test fails on main (the error points at BY) and passes here. New tests pin the empty-clause wording, and the CLI expectations are updated for the SQ0009 label.
  • The six playground examples and the basics, everyday and everyday-models corpora (2,956 queries) went through the playground's own analyze with its default settings. No outcome or converted SQL changed; 67 messages changed, all as above.
  • make check-ci passes.

@kvlonge kvlonge closed this Nov 11, 2026
@kvlonge kvlonge reopened this Nov 11, 2026
… the clause

GROUP or ORDER before BY read as a column name, so a condition left
open before the clause, as in the playground's syntax error example,
failed one token late, at BY. GROUP or ORDER before BY now always
starts the clause, and the error points at it.
…ession belongs

A statement that ended where an expression belongs, such as an empty
WHERE, reported the token before the gap: "Unexpected token: Where".
It now says what is missing: a condition after WHERE, HAVING, QUALIFY
or ON, and an expression after anything else, such as an operator.
…iased column message

The SQ0009 label named the internal node kind, such as `j_s_o_n_extract`,
and its help suggested an alias guessed from the text under the span.
For a path that was only its first name, and for a literal a quoted copy
of the literal. The label now reads plainly, and a literal or path gets
the help to add an alias without a guessed name.
@kvlonge
kvlonge force-pushed the fix/snowflake-clause-keyword-columns branch from a54615e to 3eea2bc Compare November 11, 2026 19:10
test_fixes.rs grew past the 2,000-line limit once main's tests joined
it; the tests that check where a parse error points and what it says
move to test_parse_errors.rs.
@kvlonge
kvlonge added this pull request to the merge queue Nov 11, 2026
@kvlonge
kvlonge removed this pull request from the merge queue due to a manual request Nov 11, 2026
@kvlonge
kvlonge added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 2596e1b Nov 11, 2026
13 checks passed
@kvlonge
kvlonge deleted the fix/snowflake-clause-keyword-columns branch November 11, 2026 23:30
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