Skip to content

fix: scd type 2 support table properties#5317

Merged
eakmanrq merged 1 commit intomainfrom
eakmanrq/scd_type_2_support_table_properties
Sep 8, 2025
Merged

fix: scd type 2 support table properties#5317
eakmanrq merged 1 commit intomainfrom
eakmanrq/scd_type_2_support_table_properties

Conversation

@eakmanrq
Copy link
Collaborator

@eakmanrq eakmanrq commented Sep 8, 2025

Slack context: https://tobiko-data.slack.com/archives/C044BRE5W4S/p1757327355130579

Prior to this PR, users could define a partition by on their SCD type 2 model and it wouldn't be implemented properly on follow-up inserts/appends that replace the table. This PR fixes that.

Comment on lines +2286 to 2293
return self.insert(
table_name,
query_or_df,
model,
is_first_insert=False,
render_kwargs=render_kwargs,
force_get_columns_from_target=True,
**kwargs,
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An append in this context seems to just be an insert where is_first_insert is False so updated it to reflect that and remove duplicate code.

@eakmanrq eakmanrq requested a review from Copilot September 8, 2025 16:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes SCD Type 2 model support for table properties like partitioned_by by ensuring these properties are properly passed to the adapter during follow-up inserts and appends that replace the table.

  • Consolidates insert and append methods to use the same implementation
  • Adds table properties parameters to SCD Type 2 adapter calls in the insert method
  • Updates tests to verify partition properties are preserved in SCD Type 2 operations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
sqlmesh/core/snapshot/evaluator.py Modified insert method to pass table properties to SCD adapters; simplified append method to delegate to insert
tests/core/test_snapshot_evaluator.py Added test case with partitioned_by property and verification of adapter calls
tests/core/engine_adapter/test_bigquery.py Added BigQuery-specific test to verify partition properties in SCD Type 2 operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@eakmanrq eakmanrq force-pushed the eakmanrq/scd_type_2_support_table_properties branch from 4630a89 to bc4beca Compare September 8, 2025 16:58
@eakmanrq eakmanrq force-pushed the eakmanrq/scd_type_2_support_table_properties branch from bc4beca to c6d5590 Compare September 8, 2025 17:42
@eakmanrq eakmanrq merged commit 101e73b into main Sep 8, 2025
36 checks passed
@eakmanrq eakmanrq deleted the eakmanrq/scd_type_2_support_table_properties branch September 8, 2025 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants