Repository navigation
feat(rules): read custom-rule SQL syntax trees from SQLQuack parsers - #1358
Merged
Merged
Conversation
SqlDocument is native and parses with the SQLQuack parser chosen per dialect: the native PostgreSQL parser, and the shared parser for DuckDB, MotherDuck, Snowflake and SQLite. ast() returns a SqlTreeNode tree and replaces polyglot_ast(). Other dialects, syntax errors and statements kept as unparsed text raise RuleUsageError.
…r limits as unanalysable
kvlonge
enabled auto-merge (squash)
November 8, 2026 01:22
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
Custom rules read SQL structure through a Polyglot tree that SQLBuild's analysis no longer uses, so rules and analysis could disagree. The rules tree now comes from the SQLQuack parser chosen per dialect.
Changes
SqlDocumentis native.ast()returns aSqlTreeNodetree (kind,line,column,children,walk());polyglot_ast()is removed.RuleUsageError(unavailable), as do syntax errors, PostgreSQL's stack-depth refusal, parser gaps and statements kept as unparsed text.ctes(),joins(),subqueries()andstar_projections()keep theirSqlNodeoutput. Fixes against the Polyglot version: positions are each node's own start in the source,joins()reports only explicit joins, and nestedWITHCTEs are found.star_projections()skips an aggregate's*, as before.polyglot-sql-chiodependency stays until local scenario execution moves off it.Verification
WITHmodels (Polyglot missed them). Join counts match aJOINtoken count except 1 model of commaFROMitems, fixed here with a test.ast()and each method checks positions against the source text.make check-ci, fensu, rules e2e/integration, rules benchmark unit tests. The 3,000/5,000-model rules guards time out locally on the 0.197.0 and 0.198.0 wheels too; this branch is not slower.DuckShop: not applicable; custom-rule API surface, no project shape, data value or lifecycle sequence.