Fix!: Allow expressions in scd type 2 models columns, check_cols in dbt#5529
Merged
themisvaltinos merged 3 commits intomainfrom Oct 13, 2025
Merged
Fix!: Allow expressions in scd type 2 models columns, check_cols in dbt#5529themisvaltinos merged 3 commits intomainfrom
themisvaltinos merged 3 commits intomainfrom
Conversation
41ae931 to
864dd0e
Compare
erindru
reviewed
Oct 12, 2025
sqlmesh/core/engine_adapter/base.py
Outdated
| check_columns = [exp.column(col) for col in unmanaged_columns_to_types] | ||
| if check_columns: | ||
| # Handle both Star directly and [Star()] (which can happen during serialization/deserialization) | ||
| if isinstance(check_columns, exp.Star) or ( |
Collaborator
There was a problem hiding this comment.
I think this can be represented more succinctly with the following helpers:
from sqlglot.helper import ensure_list, seq_get
if isinstance(seq_get(ensure_list(check_columns), 0), exp.Star):
...
but it's six in one, half a dozen the other
Contributor
Author
There was a problem hiding this comment.
nice that's much cleaner with seq_get thanks
erindru
approved these changes
Oct 12, 2025
864dd0e to
c248240
Compare
c248240 to
bbbb3af
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.
This adds support for expressions in the list of columns in SCD type 2 models in order to support dbt snapshots that have
check_colswith casts for example:{{ config( target_schema='snapshots', unique_key='id', strategy='check', check_cols=['ds::DATE'], ) }}Quite similar to: #2164