-
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
Changes from all commits
8145832
c22b424
8f71d29
ca01d5c
1d5ca06
d6aa961
60561f9
8bc2d40
872dae2
dda443d
7dfd836
05448ab
3507cf0
bef9eb2
b172fef
08d70cf
5c515d9
612299d
f3ddf3b
497a2fa
2042262
582be80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Features | ||
body: add enabled as a source config | ||
time: 2022-04-08T13:27:25.292454-04:00 | ||
custom: | ||
Author: nathaniel-may | ||
Issue: "3662" | ||
PR: "5008" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import itertools | ||
from pathlib import Path | ||
from typing import Iterable, Dict, Optional, Set, List, Any | ||
from typing import Iterable, Dict, Optional, Set, Any | ||
from dbt.adapters.factory import get_adapter | ||
from dbt.config import RuntimeConfig | ||
from dbt.context.context_config import ( | ||
|
@@ -137,15 +137,13 @@ def parse_source(self, target: UnpatchedSourceDefinition) -> ParsedSourceDefinit | |
tags = sorted(set(itertools.chain(source.tags, table.tags))) | ||
|
||
config = self._generate_source_config( | ||
fqn=target.fqn, | ||
target=target, | ||
rendered=True, | ||
project_name=target.package_name, | ||
) | ||
|
||
unrendered_config = self._generate_source_config( | ||
fqn=target.fqn, | ||
target=target, | ||
rendered=False, | ||
project_name=target.package_name, | ||
) | ||
|
||
if not isinstance(config, SourceConfig): | ||
|
@@ -261,19 +259,29 @@ def parse_source_test( | |
) | ||
return node | ||
|
||
def _generate_source_config(self, fqn: List[str], rendered: bool, project_name: str): | ||
def _generate_source_config(self, target: UnpatchedSourceDefinition, rendered: bool): | ||
generator: BaseContextConfigGenerator | ||
if rendered: | ||
generator = ContextConfigGenerator(self.root_project) | ||
else: | ||
generator = UnrenderedConfigGenerator(self.root_project) | ||
|
||
# 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 | ||
# 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`. | ||
Comment on lines
+274
to
+275
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. This is so useful for future us. 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. 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? |
||
precedence_configs.update(target.table.config) | ||
|
||
return generator.calculate_node_config( | ||
config_call_dict={}, | ||
fqn=fqn, | ||
fqn=target.fqn, | ||
resource_type=NodeType.Source, | ||
project_name=project_name, | ||
project_name=target.package_name, | ||
base=False, | ||
patch_config_dict=precedence_configs, | ||
) | ||
|
||
def _get_relation_name(self, node: ParsedSourceDefinition): | ||
|
This file was deleted.
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.
👍