Skip to content

Commit

Permalink
fix: check that dbt test was run
Browse files Browse the repository at this point in the history
  • Loading branch information
Vixtir committed Sep 22, 2023
1 parent 4176b34 commit 3841a25
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions odd_dbt/mapper/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,22 @@ def __init__(self, context: DbtContext, generator: DbtGenerator) -> None:

def map(self) -> DataEntityList:
data_entities = []
generic_test_nodes = self._context.manifest.generic_tests

test_results = [res for res in self._context.results if res.unique_id.startswith("test.")]

if not test_results:
raise ValueError("run_results.json doesn't contain any test result. Was dbt test command executed?")

for result in self._context.results:
for result in test_results:
try:
data_entities.extend(self.map_result(result, generic_test_nodes))
data_entities.extend(self.map_result(result, self._context.manifest.nodes))
except Exception as e:
logger.warning(f"Can't map result {result.unique_id}: {str(e)}")
logger.debug(traceback.format_exc())
continue

if not data_entities:
raise ValueError("No test results were mapped. Data will not be ingested")

data_entities = DataEntityList(
data_source_oddrn=self._generator.get_data_source_oddrn(),
Expand Down

0 comments on commit 3841a25

Please sign in to comment.