Repository navigation
feat(analysis): route each dialect's SQL analysis to Polyglot or a native module - #1354
Merged
Merged
Conversation
Adds analysis_route: a table of dialects whose SQL a native module analyses, empty for now so every dialect keeps the Polyglot path; the NativeDialect trait with read_whole; the native parser's first gap in a model's SQL, normalised and with its placeholders filled as analysis reads it; and the P026 message for a model whose analysis is skipped. Not yet wired into the model loop.
… the engine accepts A native route checks each model's analysis SQL and inline hook statements with its dialect's parser. A gap warns P026 and the model is not analysed; under require_sql_analysis it is an error. UDF and cursor stubs take the dialect's prefix, and a quoted hook parameter becomes the string literal it is filled with. On ClickHouse's native route, contract types are compared without top-level Nullable and LowCardinality, and nullability through the inferred flag. Every dialect stays on the Polyglot route until its native module is registered.
The model loop read sql_analysis_dialect from ModelInputBuildContext, which did not have the field, so every compile failed. The context now copies it from the compile adapter context.
kvlonge
enabled auto-merge (squash)
November 7, 2026 20:01
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
Each dialect's SQL analysis needs one place to move from Polyglot to a native SQLQuack module, and a safe fallback for SQL a native parser can't read yet.
Changes
analysis_route(dialect)returnsLegacyorNative(&dyn NativeDialect), keyed on the adapter's newsql_analysis_dialect.NATIVE_DIALECTSis empty, so every dialect stays on Polyglot and compile output doesn't change.require_sql_analysisP026 is an error. Skipped models get no lineage and no rules, and they never call Polyglot.stub_prefix(__sqlbuild.udf_xfor SQL Server), and a quoted@'name'becomes'__sqlbuild_parameter__name'.Nullable/LowCardinality, and nullability is compared through the inferred flag.Verification
fensu check: 0 faults.cargo clippy -D warningsis clean on sqlbuild-analysis, sqlbuild-rules and sqlbuild-python.analysis_route,contractsand rules tests pass. They cover routing, gap location after placeholders, stub spellings, the P026 message, the ClickHouse type match and rules for skipped models.