-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feature: nullable error_after in source #3955
Feature: nullable error_after in source #3955
Conversation
81137e7
to
0e083be
Compare
Here is a first proposition based on what we agreed on the initial issue. For now, the changes reflect what we agreed here, and the tests were fixed naively. Before going further and adding new tests (units and integrations), I would like your thought on the current implementation Many thanks 🙏 |
a571a94
to
d61225a
Compare
4349176
to
3d3400f
Compare
@kadero Thanks so much for the contribution! I do think it would be good to add at least one end-to-end test case in @leahwicz The logic in this PR follows an implementation I described over in #3874 (comment). I think it would be right to have an engineer from the Core team take a look, to make sure there isn't anything big that @kadero and I are both missing. |
@gshank @nathaniel-may this falls into your domain so would you be able to take a look at this please and see what you think? |
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.
The Python looks good to me and I only had one minor suggestion. I'm not deeply familiar with this corner of the code base yet so I'm going to withhold an explicit approval for now. Happy to do a more time consuming deep dive if we need to though.
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.
@kadero When you get a chance:
- Would you be able to add a test case that reproduces the desired behavior in For source freshness, allow null error_after with non-null warning_after #3874 (i.e. overrides/nulls out
error_after
only)? - Could you also add a note to the changelog (topmost section), and add yourself to the list of contributors there?
Thanks again for the contribution!
} | ||
) | ||
|
||
result_source_c = self.get_result_from_unique_id(data, 'source.test.test_source.source_c') |
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.
@kadero When you get a chance:
- Would you be able to add a test case that reproduces the desired behavior in For source freshness, allow null error_after with non-null warning_after #3874 (i.e. overrides/nulls out
error_after
only)?- Could you also add a note to the changelog (topmost section), and add yourself to the list of contributors there?
Thanks again for the contribution!
Hello @jtcohen6 @nathaniel-may 👋,
As we agreed, I created an integration test under test/integration/042_sources_test/
, where a child source (called source_c
) disables the error_after set by its parent source. 🙂
Unfortunately, the test didn't pass, everything goes on as if the child source inherit the error_after
set by its parent 😕.
Do you have any clues, are we missing something?
Many thanks your support 🙏
result_source_c['criteria'], | ||
{ | ||
'warn_after': {'count': 6, 'period': 'hour'}, | ||
'error_after': None, |
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.
return 'error_after': {'count': 24, 'period': 'hour'}
instead of 'error_after': None,
😕
) | ||
|
||
result_source_c = self.get_result_from_unique_id(data, 'source.test.test_source.source_c') | ||
self.assertEqual(result_source_c['status'], 'warn') |
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.
return error
instead of warn
https://github.com/dbt-labs/dbt-core/runs/4000597793?check_suite_focus=true#step:9:976
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.
Thanks for adding the tests, and glad we caught the unexpected behavior! I think I see the place in the logic where that's occurring
if base and update: | ||
return base.merged(update) | ||
else: | ||
return update or base |
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.
- ✅ If
base
andupdate
, merge them. This will apply ifupdate
is{}
, too - ✅ If
base
isNone
, takeupdate
- ❌ If
update
isNone
(override!), we need to returnNone
So something like:
def merge_freshness_time_thresholds(
base: Optional[Time], update: Optional[Time]
) -> Optional[Time]:
if base and update:
return base.merged(update)
elif update is None:
return None
else:
return update or base
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.
Indeed 🙈,
Thanks @jtcohen6, update done and the test is fixed ✔️
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.
Looks great @kadero! Thank you for the contribution :)
I just moved up the changelog entry, since we released v1.0.0b2
yesterday. As soon as the tests pass, I'll merge this in
* Fix tests for dbt-labs/dbt-core#3955 * Methods renamed in dbt-labs/dbt-core#4101 * Missed one
* Add nullable error after feature * add merge_error_after method * Fix FreshnessThreshold merged test * Fix other tests * Fix merge error after * Fix test docs generate integration test * Fix source integration test * Typo and fix linting. * Fix mypy test * More terse way to express merge_freshness_time_thresholds * Update Changelog.md * Add integration test * Fix conflict * Fix contributing.md * Fix integration tests * Move up changelog entry Co-authored-by: Jeremy Cohen <[email protected]> automatic commit by git-black, original commits: d2aa920
* Fix tests for dbt-labs/dbt-core#3955 * Methods renamed in dbt-labs/dbt-core#4101 * Missed one
resolves #3874
Description
This PR aims to allow overriding the
FreshnessThreshold
params (error_after
andwarning_after
).Checklist
CHANGELOG.md
and added information about my change to the "dbt next" section.