Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use common columns for incremental schema changes #38

Merged
merged 2 commits into from
Nov 8, 2021

Conversation

Kayrnt
Copy link
Contributor

@Kayrnt Kayrnt commented Oct 31, 2021

resolves dbt-labs/dbt-core#4144

Description

Using dbt-labs/dbt-core#4170 changes, the goal is to retrieve the intersection from existing table columns and the tmp table columns for the condition to avoid referencing columns that wouldn't be in one or the other table and lead to a failure of the incremental run.

BigQuery equivalent: dbt-labs/dbt-bigquery#51

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-snowflake next" section.

Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

This is working well in local testing!

Edit: After reviewing the logic in https://github.com/dbt-labs/dbt-bigquery, and trying a few more configurations, I realize that we'll need slightly different behavior for append_new_columns vs. sync_all_columns. I'll recommend a change in dbt-core accordingly.

@Kayrnt Kayrnt force-pushed the on_schema_change_columns_fix branch 3 times, most recently from 3185d26 to 0b570e2 Compare November 7, 2021 21:37
@Kayrnt Kayrnt force-pushed the on_schema_change_columns_fix branch from 0b570e2 to 1ae2790 Compare November 7, 2021 21:58
@Kayrnt Kayrnt marked this pull request as ready for review November 7, 2021 22:40
@@ -87,6 +87,21 @@ def run_incremental_append_new_columns(self):
self.list_tests_and_assert(select, exclude, expected)
self.run_tests_and_assert(select, exclude, expected, compare_source, compare_target)

def run_incremental_append_new_columns_remove_one(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Add to test below:

    @use_profile('snowflake')
    def test__snowflake__run_incremental_append_new_columns(self):
        self.run_incremental_append_new_columns()
        self.run_incremental_append_new_columns_remove_one()

@Kayrnt Kayrnt force-pushed the on_schema_change_columns_fix branch from 1ae2790 to 0fea11b Compare November 8, 2021 10:15
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

lgtm! thank you @Kayrnt!

@jtcohen6 jtcohen6 merged commit a74a1c4 into dbt-labs:main Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When on_schema_change is set, pass common columns as dest_columns in incremental merge macros
2 participants