Skip to content

Commit

Permalink
def review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Wigley committed Jun 1, 2021
1 parent 0dd940e commit cae0941
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
6 changes: 3 additions & 3 deletions core/dbt/contracts/graph/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ class TestConfig(NodeConfig):
store_failures: Optional[bool] = None
where: Optional[str] = None
limit: Optional[int] = None
fail_calc: str = "count(*)"
warn_if: str = "!= 0"
error_if: str = "!= 0"
fail_calc: str = 'count(*)'
warn_if: str = '!= 0'
error_if: str = '!= 0'

@classmethod
def same_contents(
Expand Down
12 changes: 11 additions & 1 deletion core/dbt/parser/schema_test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,34 +280,43 @@ def extract_test_args(test, name=None) -> Tuple[str, Dict[str, Any]]:
test_args['column_name'] = name
return test_name, test_args

@property
def enabled(self) -> Optional[bool]:
return self.modifiers.get('enabled')

@property
def alias(self) -> Optional[str]:
return self.modifiers.get('alias')

@property
def severity(self) -> Optional[str]:
sev = self.modifiers.get('severity')
if sev:
return sev.upper()
else:
return None

@property
def store_failures(self) -> Optional[bool]:
return self.modifiers.get('store_failures')

@property
def where(self) -> Optional[str]:
return self.modifiers.get('where')

@property
def limit(self) -> Optional[int]:
return self.modifiers.get('limit')

@property
def warn_if(self) -> Optional[str]:
return self.modifiers.get('warn_if')

@property
def error_if(self) -> Optional[str]:
return self.modifiers.get('error_if')

@property
def fail_calc(self) -> Optional[str]:
return self.modifiers.get('fail_calc')

Expand Down Expand Up @@ -346,7 +355,8 @@ def get_test_name(self) -> Tuple[str, str]:

def construct_config(self) -> str:
configs = ",".join([
f"{key}=" + (f"'{value}'" if isinstance(value, str) else str(value))
f"{key}=" + (f"'{value}'" if isinstance(value, str)
else str(value))
for key, value
in self.modifiers.items()
])
Expand Down
50 changes: 25 additions & 25 deletions core/dbt/parser/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,32 +489,32 @@ def render_test_update(self, node, config, builder):
['macro.dbt.test_not_null', 'macro.dbt.test_unique']):
self.update_parsed_node(node, config)
# manually set configs
if builder.severity() is not None:
node.unrendered_config['severity'] = builder.severity()
node.config['severity'] = builder.severity()
if builder.enabled() is not None:
node.unrendered_config['enabled'] = builder.enabled()
node.config['enabled'] = builder.enabled()
# note: this does not respect generate_alias_name() macro
if builder.alias() is not None:
node.unrendered_config['alias'] = builder.alias()
node.config['alias'] = builder.alias()
node.alias = builder.alias()
if builder.where() is not None:
node.unrendered_config['where'] = builder.where()
node.config['where'] = builder.where()
if builder.limit() is not None:
node.unrendered_config['limit'] = builder.limit()
node.config['limit'] = builder.limit()
if builder.warn_if() is not None:
node.unrendered_config['warn_if'] = builder.warn_if()
node.config['warn_if'] = builder.warn_if()
if builder.error_if() is not None:
node.unrendered_config['error_if'] = builder.error_if()
node.config['error_if'] = builder.error_if()
if builder.fail_calc() is not None:
node.unrendered_config['fail_calc'] = builder.fail_calc()
node.config['fail_calc'] = builder.fail_calc()
if builder.alias is not None:
node.unrendered_config['alias'] = builder.alias
node.config['alias'] = builder.alias
node.alias = builder.alias
if builder.severity is not None:
node.unrendered_config['severity'] = builder.severity
node.config['severity'] = builder.severity
if builder.enabled is not None:
node.unrendered_config['enabled'] = builder.enabled
node.config['enabled'] = builder.enabled
if builder.where is not None:
node.unrendered_config['where'] = builder.where
node.config['where'] = builder.where
if builder.limit is not None:
node.unrendered_config['limit'] = builder.limit
node.config['limit'] = builder.limit
if builder.warn_if is not None:
node.unrendered_config['warn_if'] = builder.warn_if
node.config['warn_if'] = builder.warn_if
if builder.error_if is not None:
node.unrendered_config['error_if'] = builder.error_if
node.config['error_if'] = builder.error_if
if builder.fail_calc is not None:
node.unrendered_config['fail_calc'] = builder.fail_calc
node.config['fail_calc'] = builder.fail_calc
# source node tests are processed at patch_source time
if isinstance(builder.target, UnpatchedSourceDefinition):
sources = [builder.target.fqn[-2], builder.target.fqn[-1]]
Expand Down

0 comments on commit cae0941

Please sign in to comment.