-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 unit tests for incremental models with alias #10755
Fix unit tests for incremental models with alias #10755
Conversation
Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA. In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR. CLA has not been signed by users: @katsugeneration |
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10755 +/- ##
==========================================
+ Coverage 88.97% 88.98% +0.01%
==========================================
Files 181 181
Lines 22956 22977 +21
==========================================
+ Hits 20424 20447 +23
+ Misses 2532 2530 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the targeted solution and the nice functional test @katsugeneration 🤩
I can confirm that running the following test fails without the fix, but succeeds with the test in place:
python -m pytest tests/functional/unit_testing/test_unit_testing.py::TestUnitTestIncrementalModelWithAlias```
class TestUnitTestIncrementalModelWithAlias: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"my_incremental_model.sql": my_incremental_model_with_alias_sql, | ||
"events.sql": event_sql, | ||
"schema.yml": test_my_model_incremental_yml_basic, | ||
} | ||
|
||
def test_basic(self, project): | ||
results = run_dbt(["run"]) | ||
assert len(results) == 2 | ||
|
||
# Select by model name | ||
results = run_dbt(["test", "--select", "my_incremental_model"], expect_pass=True) | ||
assert len(results) == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests the regression reported in #10754.
I confirmed this test fails without the fix but succeeds with the fix in place:
python -m pytest tests/functional/unit_testing/test_unit_testing.py::TestUnitTestIncrementalModelWithAlias
class TestUnitTestIncrementalModelWithVersion: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"my_incremental_model.sql": my_incremental_model_sql, | ||
"events.sql": event_sql, | ||
"schema.yml": my_incremental_model_versioned_yml + test_my_model_incremental_yml_basic, | ||
} | ||
|
||
def test_basic(self, project): | ||
results = run_dbt(["run"]) | ||
assert len(results) == 2 | ||
|
||
# Select by model name | ||
results = run_dbt(["test", "--select", "my_incremental_model"], expect_pass=True) | ||
assert len(results) == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests the regression reported in #10763.
I confirmed this test fails without the fix but succeeds with the fix in place:
python -m pytest tests/functional/unit_testing/test_unit_testing.py::TestUnitTestIncrementalModelWithVersion
@@ -1636,7 +1636,7 @@ def this(self) -> Optional[str]: | |||
if self.model.this_input_node_unique_id: | |||
this_node = self.manifest.expect(self.model.this_input_node_unique_id) | |||
self.model.set_cte(this_node.unique_id, None) # type: ignore | |||
return self.adapter.Relation.add_ephemeral_prefix(this_node.name) | |||
return self.adapter.Relation.add_ephemeral_prefix(this_node.identifier) # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The root causes of the regressions reported in #10754 and #10763 was that:
- the update from
this_node.name
tothis_node.identifier
was accidentally overlooked during the implementation and code review of https://github.com/dbt-labs/dbt-core/pull/10290/files, and - there were no functional tests to catch those particular cases
This PR addresses both of those root causes ✅ ✅
(cherry picked from commit a8d4ba2)
(cherry picked from commit a8d4ba2) Co-authored-by: Katsuya Shimabukuro <[email protected]> Co-authored-by: Gerda Shank <[email protected]>
Hey @dbeatty10 , will this fix be included in |
Resolves #10754
Resolves #10763
Problem
this
models with aliasSolution
this
referrence name in UnitTestContext to based on alias name on incremental modelChecklist