Repository navigation
fix(compiler): reject reference calls that compile cannot replace - #1011
Merged
Merged
Conversation
kvlonge
enabled auto-merge (squash)
October 7, 2026 19:38
Reference extraction accepted unquoted names, single-quoted names, and whitespace or comments inside __ref(), __source(), __seed(), __udf(), __table_fn() and __dbt_ref() calls, but compile replacement only rewrites the double-quoted form. Those models then failed with misleading analysis errors. Extraction now accepts exactly the replaceable form and reports P012 with the corrected call.
Report P012 through the compile diagnostic collector with the authored file, line, column and resource, so one compile lists every rejected call instead of stopping at the first. Calls returned by a macro are attributed to the macro with a pass-the-reference-in hint, and models with a rejected call skip SQL analysis instead of adding B-errors. Scenario relation rewriting now matches only the double-quoted form, and example calls in messages use double quotes. The preview-tier native reference scanner accepts only the bare double-quoted form and defers every other call to Python, which reports P012, so native and Python compiles stay identical and the mismatch check never fires on rejected calls.
kvlonge
force-pushed
the
fix/unquoted-ref-arguments
branch
from
October 7, 2026 20:41
48cedd4 to
dedb819
Compare
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
Extraction accepted
__ref(stg_orders),__ref('stg_orders'), spaces and comments inside reference calls, but compile only replaces__ref("stg_orders"), so those models failed with misleading B002/B004/B101 errors. The docs only show the double-quoted form, so the other forms are now rejected.Changes
__ref,__source,__seed,__udf,__table_fnand__dbt_refaccept exactly one double-quoted name, with nothing else inside the parentheses (__dbt_refalso takes"package", "name"). Anything else is a newP012error, as is a__table_fncall with no argument list.P012points at the call's file, line and column, names the model, and shows the corrected call. One compile reports every rejected call. SQL analysis is skipped, so no B-errors appear.@macro(__ref("name")). P006 checks of the macro's other calls still run.__assert__CTEs, no longer accepts__ref(x),__ref('x')or spaced forms. The scenario relation rewrite now only matches the double-quoted form.P012.Verification
cargo fmt/clippy/test --workspace --all-featureswith 1.98.0.make compiler-differential(+-shipped),tests/e2e/scripts/compiler_differential,make check-ci,make test.