Fix: Only keep refs and sources that exist to match dbt load time behaviour#5509
Merged
themisvaltinos merged 3 commits intomainfrom Oct 8, 2025
Merged
Fix: Only keep refs and sources that exist to match dbt load time behaviour#5509themisvaltinos merged 3 commits intomainfrom
themisvaltinos merged 3 commits intomainfrom
Conversation
izeigerman
approved these changes
Oct 8, 2025
georgesittas
approved these changes
Oct 8, 2025
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.
During parsing sqlmesh captures all
refs/sourcesincluding those that might be in{% if false %}blocks. For example the below model would lead at load time error in sqlmesh by failing on the missing reference:{{ config( materialized='table', ) }} {% if true %} WITH source AS ( SELECT * FROM {{ ref('simple_model_a') }} ) {% else %} WITH source AS ( SELECT * FROM {{ ref('nonexistent_model') }} -- this doesn't exist but is in unexecuted branch ) {% endif %} SELECT * FROM sourceDbt on the other hand happily proceeds at load time and then since the branch is never exercised runs the model successfully. If there was an actual missing reference it would fail at runtime. So this aims to match this behaviour by intersecting static analysis results with dbt's manifest refs and sources so that we not raise at load time.