Skip to content

fix(lint): stop panicking on a query that ends in FROM - #165

Merged
kvlonge merged 1 commit into
mainfrom
fix/lint-trailing-from
Nov 10, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/lint-trailing-from

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Why

Linting WITH t AS (SELECT 1) SELECT * FROM as Databricks panicked in the terminal-shape check with an out-of-range slice. Databricks is the one parser that accepts a final FROM with no relation, so lint reached the slice after that FROM. A panic there takes down any process that lints in-process.

Changes

  • The terminal-shape check reads the tokens after the relation with a bounded get, so a FROM at the end of the query yields an empty remainder instead of a panic. Databricks now reports the SQLCLEAN035 terminal-shape finding for this input.
  • A regression test lints the same input on every parsed dialect: Snowflake, DuckDB, SQLite, PostgreSQL, Generic and BigQuery refuse it with a parse error, and Databricks lints it.

Verification

  • The new test fails on main with the panic at terminal_shape.rs:212 and passes with the change; all sqlquack-lint tests pass.
  • The other slices in the terminal-shape helpers, and the one + 2 slice elsewhere in sqlquack-lint, are already bounded by a get or a length check.
  • clippy -D warnings, fensu (0 faults), the clutter guard and make check-ci pass.

The terminal-shape check sliced the tokens two past the final FROM, which
runs past the end when FROM is the last token. Databricks parses such a
query, so linting it panicked. The check now reads that remainder with a
bounded get, and Databricks reports the terminal-shape finding instead.

A regression test lints the same query on every parsed dialect: the other
six refuse it with a parse error.
@kvlonge
kvlonge merged commit 4ae2e6a into main Nov 10, 2026
8 checks passed
@kvlonge
kvlonge deleted the fix/lint-trailing-from branch November 10, 2026 23:36
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