Skip to content
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

Merged
merged 22 commits into from
Apr 12, 2022
Merged

Add enabled as a source config #5008

merged 22 commits into from
Apr 12, 2022

Conversation

emmyoop
Copy link
Member

@emmyoop emmyoop commented Apr 7, 2022

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

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have added information about my change to be included in the CHANGELOG.

@cla-bot cla-bot bot added the cla:yes label Apr 7, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2022

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.

@emmyoop emmyoop changed the base branch from main to feature/ct-201-source-config April 7, 2022 18:15
@emmyoop emmyoop closed this Apr 7, 2022
@emmyoop emmyoop reopened this Apr 7, 2022
@emmyoop emmyoop added the Skip Changelog Skips GHA to check for changelog file label Apr 7, 2022
@emmyoop emmyoop changed the base branch from feature/ct-201-source-config to main April 7, 2022 18:27
Copy link
Contributor

@jtcohen6 jtcohen6 left a 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.

Comment on lines 269 to 276
# 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)
Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nathaniel-may
Copy link
Contributor

blocked on #5015

@nathaniel-may nathaniel-may changed the title [WIP] First pass at adding enabled as a config Add enabled as a source config Apr 8, 2022
@nathaniel-may nathaniel-may marked this pull request as ready for review April 8, 2022 17:22
@nathaniel-may
Copy link
Contributor

nathaniel-may commented Apr 8, 2022

looking into the one remaining failure.
failing sql value: '\ncreate schema if not exists test16494413810009909306_test_permissions'

@emmyoop emmyoop removed the Skip Changelog Skips GHA to check for changelog file label Apr 11, 2022
Comment on lines +274 to +275
# 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`.
Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

@emmyoop emmyoop left a 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.

Copy link
Contributor

@gshank gshank left a 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.

core/dbt/contracts/graph/unparsed.py Show resolved Hide resolved
Comment on lines +274 to +275
# 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`.
Copy link
Contributor

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?

@nathaniel-may
Copy link
Contributor

Also not approving since I wrote some of this as well. Thanks for the review, @gshank!

@emmyoop emmyoop merged commit cce8fda into main Apr 12, 2022
@emmyoop emmyoop deleted the er/slim-down-requirements branch April 12, 2022 15:27
VersusFacit pushed a commit that referenced this pull request Apr 14, 2022
* 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]>
agoblet pushed a commit to BigDataRepublic/dbt-core that referenced this pull request May 20, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-201] Reconcile configs + properties for sources
5 participants