Skip to content

Commit

Permalink
Fix upgrade_schema bug to keep metrics data
Browse files Browse the repository at this point in the history
Signed-off-by: Ching Yi, Chan <[email protected]>
Co-authored-by: wcchang <[email protected]>
Co-authored-by: popcorny <[email protected]>
  • Loading branch information
3 people committed Sep 4, 2023
1 parent 2ed2b8f commit e83b756
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion piperider_cli/dbt/list_task.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import json
import re
import tempfile
from dataclasses import fields
from pathlib import Path
Expand Down Expand Up @@ -103,7 +104,23 @@ def _load_manifest_version_15(manifest: Dict):
]
raise ValueError(messages)

return WritableManifest.upgrade_schema_version(data)
def patched_get_manifest_schema_version(dct: dict) -> int:
schema_version = dct.get("metadata", {}).get("dbt_schema_version", None)
if not schema_version:
raise ValueError("Manifest doesn't have schema version")

Check warning on line 110 in piperider_cli/dbt/list_task.py

View check run for this annotation

Codecov / codecov/patch

piperider_cli/dbt/list_task.py#L110

Added line #L110 was not covered by tests

match = re.search(r'/v(\d+).json', schema_version)
if match:
return int(match.group(1))
raise ValueError("Manifest doesn't have schema version")

Check warning on line 115 in piperider_cli/dbt/list_task.py

View check run for this annotation

Codecov / codecov/patch

piperider_cli/dbt/list_task.py#L115

Added line #L115 was not covered by tests

import dbt.contracts.graph.manifest
origin_function = dbt.contracts.graph.manifest.get_manifest_schema_version
dbt.contracts.graph.manifest.get_manifest_schema_version = patched_get_manifest_schema_version

result = WritableManifest.upgrade_schema_version(data)
dbt.contracts.graph.manifest.get_manifest_schema_version = origin_function
return result


def _load_manifest_version_16(manifest: Dict):
Expand Down
2 changes: 1 addition & 1 deletion piperider_cli/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ def _slim_dbt_manifest(manifest):
if not _check_assertion_status(assertion_results, assertion_exceptions):
return EC_ERR_TEST_FAILED

if len(subjects) == 0:
if len(run_result.get('tables', {})) == 0 and len(run_result.get('metrics', [])) == 0:
return EC_WARN_NO_PROFILED_MODULES

return 0

0 comments on commit e83b756

Please sign in to comment.