Repository navigation
fix(lint): stop panicking on a query that ends in FROM - #165
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Linting
WITH t AS (SELECT 1) SELECT * FROMas 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
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.Verification
terminal_shape.rs:212and passes with the change; all sqlquack-lint tests pass.+ 2slice elsewhere in sqlquack-lint, are already bounded by agetor a length check.make check-cipass.