-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add dbt freshness check test #18730
Merged
TeddyCr
merged 19 commits into
open-metadata:main
from
mgorsk1:feat/support-dbt-freshness-check-test
Nov 28, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
086e27b
add dbt freshness check
mgorsk1 aa3acd4
docs
mgorsk1 3ea615d
run linting
mgorsk1 79da538
add test case param definition
mgorsk1 83e6af4
fix test case param definition
mgorsk1 836563b
add config for dbt http, fix linting
mgorsk1 8fb79a4
refactor (only create freshness test definition when user executed one)
mgorsk1 2b914e9
Merge branch 'main' into feat/support-dbt-freshness-check-test
mgorsk1 4ab97c7
Merge branch 'main' into feat/support-dbt-freshness-check-test
TeddyCr 3f4c408
fix dbt files class
mgorsk1 5992cd0
Merge branch 'main' into feat/support-dbt-freshness-check-test
mgorsk1 80274a0
fix dbt files class 2
mgorsk1 127850a
fix dbt objects class
mgorsk1 9135c0d
fix linting
mgorsk1 c6a6f34
fix pylint
mgorsk1 d5d937f
fix linting once and for all
mgorsk1 23d727a
Merge branch 'main' into feat/support-dbt-freshness-check-test
mgorsk1 d386555
Merge branch 'main' into feat/support-dbt-freshness-check-test
mgorsk1 ae5954c
Merge branch 'main' into feat/support-dbt-freshness-check-test
mgorsk1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,20 @@ def create_test_case_parameter_definitions(dbt_test): | |
} | ||
] | ||
return test_case_param_definition | ||
if hasattr(dbt_test, "freshness"): | ||
test_case_param_definition = [ | ||
{ | ||
"name": "warn_after", | ||
"displayName": "warn_after", | ||
"required": False, | ||
}, | ||
{ | ||
"name": "error_after", | ||
"displayName": "error_after", | ||
"required": False, | ||
}, | ||
] | ||
return test_case_param_definition | ||
except Exception as err: # pylint: disable=broad-except | ||
logger.debug(traceback.format_exc()) | ||
logger.error( | ||
|
@@ -67,6 +81,21 @@ def create_test_case_parameter_values(dbt_test): | |
{"name": manifest_node.test_metadata.name, "value": dbt_test_values} | ||
] | ||
return test_case_param_values | ||
if hasattr(manifest_node, "freshness"): | ||
warn_after = manifest_node.freshness.warn_after | ||
error_after = manifest_node.freshness.error_after | ||
|
||
test_case_param_values = [ | ||
{ | ||
"name": "error_after", | ||
"value": f"{error_after.count} {error_after.period.value}", | ||
}, | ||
{ | ||
"name": "warn_after", | ||
"value": f"{warn_after.count} {warn_after.period.value}", | ||
}, | ||
] | ||
Comment on lines
+84
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question here for the "name" values There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar answer |
||
return test_case_param_values | ||
except Exception as err: # pylint: disable=broad-except | ||
logger.debug(traceback.format_exc()) | ||
logger.error( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be gotten from the dbt_test object similar to how we do it above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it cannot, freshness check has different model than regular test: https://schemas.getdbt.com/dbt/sources/v3/index.html#tab-pane_results_items_anyOf_i1
and it's not stored in run_results.json
what we could do is
test_case_param_definition = [ {"name": x, "displayName": x, "required": False} for x in dbt_test.criteria.keys() ]
but criteria object also containsfilter
and I didn't want to include it.