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

Fix/incremental column precision changes #5395

Merged
merged 7 commits into from
Aug 12, 2022

Conversation

epapineau
Copy link
Contributor

resolves #5351

Description

Consider whether column may be successfully expanded when qualifying schema changes

Checklist

@epapineau epapineau requested a review from a team June 18, 2022 02:37
@epapineau epapineau requested review from a team as code owners June 18, 2022 02:37
@cla-bot cla-bot bot added the cla:yes label Jun 18, 2022
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@@ -63,6 +63,12 @@ def run_incremental_sync_remove_only(self):
compare_target = 'incremental_sync_remove_only_target'
self.run_twice_and_assert(select, compare_source, compare_target)

def run_incremental_sync_shorter_cols(self):
select = 'model_a incremental_sync_shorter_columns incremental_sync_shorter_target'
Copy link
Contributor

@ChenyuLInx ChenyuLInx Jun 23, 2022

Choose a reason for hiding this comment

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

@epapineau thanks for contributing and adding the tests! I tried to run the test locally and it actually didn't pass. incremental_sync_shorter_columns_target should be the last model selected here I think. But even after adjusting it still fails. Do you think you can update the test case a bit so that it replicates the issue that happened in #5395 and would fail without your change in the macro but passes afterwards?

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, this function won't actually run unless you have a test function that actually runs it. something like

    @use_profile('postgres')
    def test__postgres__run_incremental_sync_shorter_cols(self):
        self.run_incremental_sync_shorter_cols()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback @ChenyuLInx. I don't think this bug exists on postgres - I was only able to recreate on Snowflake & Redshift (didn't try on BigQuery). Am I able to pass a different test db as a value for @use_profile()?

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, we don't really have another option in dbt-core, so I think we should probably just add the code here, and add a test in dbt-snowflake or dbt-redshift separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ChenyuLInx Thanks for your feedback on Friday. I took a stab at writing the test in dbt/tests/adapter, let me know what you think 🎉

Copy link
Contributor

@ChenyuLInx ChenyuLInx left a comment

Choose a reason for hiding this comment

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

@epapineau Thanks for moving the test into an adapter test!!

This all looks good! Just want to double-check, running the test in dbt-snowflake/redshift before your fix would cause the test to fail right?

tests/adapter/dbt/tests/adapter/basic/test_incremental.py Outdated Show resolved Hide resolved
class Testincremental(BaseIncremental):
pass


class TestBaseIncrementalNotSchemaChange(BaseIncrementalNotSchemaChange):
Copy link
Contributor

Choose a reason for hiding this comment

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

Great!! Can we also add this test in dbt-snowflake and dbt-redshift?

@jtcohen6 jtcohen6 added ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering Team:Adapters Issues designated for the adapter area of the code labels Jun 28, 2022
@leahwicz
Copy link
Contributor

leahwicz commented Jul 6, 2022

@epapineau is this PR ready to merge in? We are getting ready to cut the RC branch for 1.2 soon so just trying to get any last PRs in before that happens

@epapineau
Copy link
Contributor Author

@leahwicz Sorry for the delay in responding, I'm just getting caught back up after two weeks of PTO. Let me confirm the test fails as @ChenyuLInx asked and then this is ready to merge

@ChenyuLInx
Copy link
Contributor

Paired with @epapineau today and adjusted the test to make sure it will fail on snowflake before applying the fix

@ChenyuLInx ChenyuLInx merged commit 348769f into main Aug 12, 2022
@ChenyuLInx ChenyuLInx deleted the fix/incremental-column-precision-changes branch August 12, 2022 21:54
VersusFacit pushed a commit that referenced this pull request Sep 5, 2022
* Only consider schema change when column cannot be expanded

* Add test for column shortening

* Add changelog entry

* Move test from integration to adapter tests

* Remove print statement

* add on_schema_change
agoblet pushed a commit to BigDataRepublic/dbt-core that referenced this pull request Sep 16, 2022
* Only consider schema change when column cannot be expanded

* Add test for column shortening

* Add changelog entry

* Move test from integration to adapter tests

* Remove print statement

* add on_schema_change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering Team:Adapters Issues designated for the adapter area of the code
Projects
None yet
4 participants