Skip to content

Commit

Permalink
[Bug] Fix upgrade_schema bug to keep metrics data (#871)
Browse files Browse the repository at this point in the history
* Fix upgrade_schema bug to keep metrics data

Signed-off-by: Ching Yi, Chan <[email protected]>
Co-authored-by: wcchang <[email protected]>
Co-authored-by: popcorny <[email protected]>

* Update no-profiled criteria

Signed-off-by: Ching Yi, Chan <[email protected]>

---------

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 authored Sep 4, 2023
1 parent 2ed2b8f commit fb1bbdc
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")

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

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(subjects) == 0 and len(run_result.get('metrics', [])) == 0:
return EC_WARN_NO_PROFILED_MODULES

return 0

0 comments on commit fb1bbdc

Please sign in to comment.