Repository navigation
fix(analysis): one 256 function-call depth for Polyglot and SQLQuack's shared parsers - #1596
Merged
Merged
Conversation
A Snowflake SQL macro whose body nests 65 REPLACE calls failed to compile with P015 "E_GUARD_FUNCTION_NESTING_DEPTH_EXCEEDED: value 65 exceeds configured limit 64". The native Snowflake module, which parses macro bodies and models since v0.208.0, passed SQLQuack's default options, so the library's 64-call guard applied. Other parse paths set their own limit (128 in query facts and Polyglot query analysis, 512 elsewhere) or none, so the same SQL passed one command and failed another. Every Polyglot and SQLQuack parse now takes its options from sqlbuild_analysis::parse_guard, whose one MAX_FUNCTION_CALL_DEPTH is 256, as SQLQuack's own guarded parse uses. Python's Polyglot proxy reads the same constant from the native module. Both parsers grow their stack on demand and keep their parser-depth (1,024) and AST-depth (512) limits; tests parse 256 nested calls with each guarded parser on a 2 MiB thread and check one more names the limit. A macro nested past it still fails with P015 naming the model, both lines and limit 256. `make check-ci` gains check-parse-guard, which fails when a crate source parses with a library default: ParseOptions::default(), an option literal without complexity_guard, a bare Polyglot parse, or a local depth. SQLClean rules parse inside sqlquack-lint with its own limit of 128, which SQLBuild cannot set.
…come Refs: fensu FPRST202/FPRST404
The parse guard, native stub, native layering and release gate checks each parsed --root, listed their errors under a heading and printed a success line in the same way. They now share run_root_check and keep only what they check and the messages they print.
…e its gaps The shared 256 function-call depth covers every Polyglot parse and SQLQuack's shared and Snowflake parsers. SQLQuack's per-dialect parser crates (BigQuery, ClickHouse, Databricks, DuckDB, PostgreSQL, SQLite and T-SQL) take no options and keep their own built-in limits, so they are a documented exclusion until SQLQuack accepts options for them. The module docs and the check's messages now say so instead of every SQL parse. - Semantic validation always applies the shared guard; a request's own guard no longer overrides it. - Query enrichment sets the typed guard on its analysis options instead of round-tripping it through JSON. - The guarded_parse_options and proxy_parse_options pass-throughs, which could not fail, are gone; callers use polyglot_parse_options directly. - The parse-guard check also flags a ParseOptions literal without a guard and a parse_data_type call without options.
kvlonge
enabled auto-merge
November 19, 2026 12:23
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 19, 2026
…e compiler The built-in model rules' query facts now share the compiler's 256 function-call depth, so SQL nested 130 calls deep, once beyond their 128 budget, is evaluated. The unevaluated-resource case for SQBRMODEL101 becomes a case that the rule evaluates it; SQLClean rules keep their own budget and their unevaluated cases stay.
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
A Snowflake SQL macro whose body nests 65
REPLACEcalls failed to compile with P015: the native Snowflake parser used SQLQuack's default 64-call guard. Other parse paths set 128, 512 or no limit, so the same SQL passed one command and failed another.Changes
sqlbuild_analysis::parse_guardholds oneMAX_FUNCTION_CALL_DEPTHof 256 (SQLQuack's own guarded depth). Every Polyglot parse and SQLQuack's shared and Snowflake parsers take their options from it; Python's Polyglot proxy reads the same constant from the native module.make check-cigainscheck-parse-guard, which fails on library-default options, unguarded option literals (includingParseOptions { .. }), bare Polyglot parses,parse_data_typewithout options, or a local depth.Verification
make check-ci; one review plus follow-up.