-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add enabled as a source config #5008
Conversation
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
d0210ec
to
edd270b
Compare
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.
Whoops, I left my comments in #5003 instead of here. Some of the context there may still be helpful/interesting to you, specifically the piece about unrendered_config
.
In any case, I think you're on the right track here! Looks good in local testing. I'd be very happy about shipping this as a standalone piece of net-new functionality in v1.1.
core/dbt/parser/sources.py
Outdated
# configs with precendence set | ||
precedence_configs = dict() | ||
# first apply source configs | ||
precedence_configs.update(target.source.config) | ||
# then overrite anything that is defined on source tables | ||
precedence_configs.update(target.table.config) |
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.
Yep, nice! This solves for #5003 (comment)
The logic here might get trickier when trying to account for configs that can also be defined as top-level node keys. For just enabled
, though, this is perfect
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.
yeah this is the part that I really wasn't sure was a good idea. Is there a merge_config_dict
function of sorts that will handle some of this?
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.
added a comment to this effect at the very least.
@@ -335,6 +335,40 @@ def replace(self, **kwargs): | |||
@dataclass | |||
class SourceConfig(BaseConfig): | |||
enabled: bool = True | |||
# to be implmented to complete CT-201 |
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.
👍
blocked on #5015 |
Co-authored-by: Jeremy Cohen <[email protected]>
Co-authored-by: Jeremy Cohen <[email protected]>
313a3ad
to
08d70cf
Compare
looking into the one remaining failure. |
# this is not quite complex enough for configs that can be set as top-level node keys, but | ||
# it works while source configs can only include `enabled`. |
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.
This is so useful for future us.
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.
In the other nodes configs are merged by the code in the BaseConfig object, in the 'update_from' method, which handles merging things like tags and meta, etc. (MergeBehavior, etc). Which is called by 'calculate_node_config'. I imagine you'll need to use some of that code to handle merging the Source configs with the SourceTable configs?
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.
This looks good to me as a first step to the end goal. I'm not going to approve it since I wrote some of it too! I think it would be great if @gshank could take a look.
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 good. I left a few comments. The merging of configs will have to be handled eventually but that can happen in the next phase.
# this is not quite complex enough for configs that can be set as top-level node keys, but | ||
# it works while source configs can only include `enabled`. |
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.
In the other nodes configs are merged by the code in the BaseConfig object, in the 'update_from' method, which handles merging things like tags and meta, etc. (MergeBehavior, etc). Which is called by 'calculate_node_config'. I imagine you'll need to use some of that code to handle merging the Source configs with the SourceTable configs?
Also not approving since I wrote some of this as well. Thanks for the review, @gshank! |
* initial pass at source config test w/o overrides * Update tests/functional/sources/test_source_configs.py Co-authored-by: Jeremy Cohen <[email protected]> * Update tests/functional/sources/test_source_configs.py Co-authored-by: Jeremy Cohen <[email protected]> * tweaks from feedback * clean up some test logic - add override tests * add new fields to source config class * fix odd formatting * got a test working * removed unused tests * removed extra fields from SourceConfig class * fixed next failing unit test * adding back missing import * first pass at adding source table configs * updated remaining tests to pass * remove source override tests * add comment for config merging * changelog * remove old comments * hacky fix for permission test * remove unhelpful test * adding back test file that was accidentally deleted Co-authored-by: Jeremy Cohen <[email protected]> Co-authored-by: Nathaniel May <[email protected]> Co-authored-by: Chenyu Li <[email protected]>
* initial pass at source config test w/o overrides * Update tests/functional/sources/test_source_configs.py Co-authored-by: Jeremy Cohen <[email protected]> * Update tests/functional/sources/test_source_configs.py Co-authored-by: Jeremy Cohen <[email protected]> * tweaks from feedback * clean up some test logic - add override tests * add new fields to source config class * fix odd formatting * got a test working * removed unused tests * removed extra fields from SourceConfig class * fixed next failing unit test * adding back missing import * first pass at adding source table configs * updated remaining tests to pass * remove source override tests * add comment for config merging * changelog * remove old comments * hacky fix for permission test * remove unhelpful test * adding back test file that was accidentally deleted Co-authored-by: Jeremy Cohen <[email protected]> Co-authored-by: Nathaniel May <[email protected]> Co-authored-by: Chenyu Li <[email protected]>
resolves #3662
Description
This only adds enabled as a config. Tests have been slimmed down to show what is expected to work. Since you can't set enabled as a property currently, we don't need to deal with overrides.
enabled
as a config is also highly valuable to the users of dbt.The rest of the configs will be added in #5003.
Checklist