Skip to content

Commit

Permalink
dbt: filter non-test nodes while processing assertions (apache#422)
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Obuchowski <[email protected]>
  • Loading branch information
mobuchowski authored Dec 3, 2021
1 parent a878bed commit 3cf23e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* dbt: column descriptions are properly filled from metadata.json [@mobuchowski](https://github.com/mobuchowski)
* dbt: allow parsing artifacts with version higher than officially supported [@mobuchowski](https://github.com/mobuchowski)
* dbt: dbt build command is supported [@mobuchowski](https://github.com/mobuchowski)

* dbt: fix crash when build command is used with seeds in dbt 1.0.0rc3 [@mobuchowski](https://github.com/mobuchowski)

## [0.3.1](https://github.com/OpenLineage/OpenLineage/releases/tag/0.3.1) - 2021-10-21

Expand Down
6 changes: 3 additions & 3 deletions integration/common/openlineage/common/provider/dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ def parse(self) -> DbtEvents:
"""
Parse dbt manifest and run_result and produce OpenLineage events.
"""
manifest = self.load_metadata(self.manifest_path, [2, 3], self.logger)
run_result = self.load_metadata(self.run_result_path, [2, 3], self.logger)
manifest = self.load_metadata(self.manifest_path, [2, 3, 4], self.logger)
run_result = self.load_metadata(self.run_result_path, [2, 3, 4], self.logger)
self.run_metadata = run_result['metadata']
self.command = run_result['args']['which']

Expand Down Expand Up @@ -418,9 +418,9 @@ def parse_assertions(
) -> Dict[str, List[Assertion]]:
assertions = collections.defaultdict(list)
for run in context.run_results['results']:
test_node = nodes[run['unique_id']]
if not run['unique_id'].startswith('test.'):
continue
test_node = nodes[run['unique_id']]

model_node = None
for node in context.manifest['parent_map'][run['unique_id']]:
Expand Down
14 changes: 13 additions & 1 deletion integration/common/tests/dbt/test_dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import attr
import pytest

from openlineage.common.provider.dbt import DbtArtifactProcessor, ParentRunMetadata
from openlineage.common.provider.dbt import DbtArtifactProcessor, ParentRunMetadata, DbtRunContext
from openlineage.client import set_producer
from openlineage.common.test import match

Expand Down Expand Up @@ -211,3 +211,15 @@ def test_logging_handler_does_not_warn():
DbtArtifactProcessor.load_metadata(path, [2], logger)

logger.warning.assert_not_called()


def test_seed_snapshot_nodes_do_not_throw():
processor = DbtArtifactProcessor(
producer='https://github.com/OpenLineage/OpenLineage/tree/0.0.1/integration/dbt',
project_dir='tests/dbt/test',
)

# Should just skip processing
processor.parse_assertions(
DbtRunContext({}, {"results": [{"unique_id": "seed.jaffle_shop.raw_orders"}]}), {}
)

0 comments on commit 3cf23e9

Please sign in to comment.