Skip to content

Commit

Permalink
Fix unit test parsing to ensure external nodes continue to keep their…
Browse files Browse the repository at this point in the history
… package name
  • Loading branch information
QMalcolm committed Jan 12, 2024
1 parent ec0ed32 commit 7fa5e5c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/dbt/parser/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def parse_unit_test_case(self, test_case: UnitTestDefinition):

common_fields = {
"resource_type": NodeType.Model,
"package_name": test_case.package_name,
"original_file_path": original_input_node.original_file_path,
"config": ModelConfig(materialized="ephemeral"),
"database": original_input_node.database,
Expand All @@ -137,7 +136,8 @@ def parse_unit_test_case(self, test_case: UnitTestDefinition):
input_name = f"{unit_test_node.name}__{original_input_node.name}"
input_node = ModelNode(
**common_fields,
unique_id=f"model.{test_case.package_name}.{input_name}",
package_name=original_input_node.package_name,
unique_id=f"model.{original_input_node.package_name}.{input_name}",
name=input_name,
path=original_input_node.path,
)
Expand All @@ -148,7 +148,8 @@ def parse_unit_test_case(self, test_case: UnitTestDefinition):
input_name = f"{unit_test_node.name}__{original_input_node.search_name}__{original_input_node.name}"
input_node = UnitTestSourceDefinition(

Check warning on line 149 in core/dbt/parser/unit_tests.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/parser/unit_tests.py#L148-L149

Added lines #L148 - L149 were not covered by tests
**common_fields,
unique_id=f"model.{test_case.package_name}.{input_name}",
package_name=original_input_node.package_name,
unique_id=f"model.{original_input_node.package_name}.{input_name}",
name=original_input_node.name, # must be the same name for source lookup to work
path=input_name + ".sql", # for writing out compiled_code
source_name=original_input_node.source_name, # needed for source lookup
Expand Down

0 comments on commit 7fa5e5c

Please sign in to comment.