Compare commits

...

1 Commits

Author SHA1 Message Date
Kyle Wigley
8612ce4295 cause test failure using membership operator with node.config 2021-07-13 17:59:36 -04:00
2 changed files with 33 additions and 4 deletions

View File

@@ -2,13 +2,13 @@ from dataclasses import field, Field, dataclass
from enum import Enum
from itertools import chain
from typing import (
Any, List, Optional, Dict, Union, Type, TypeVar
Any, List, Optional, Dict, Union, Type, TypeVar, Callable
)
from dbt.dataclass_schema import (
dbtClassMixin, ValidationError, register_pattern,
dbtClassMixin, ValidationError, register_pattern
)
from dbt.contracts.graph.unparsed import AdditionalPropertiesAllowed
from dbt.exceptions import InternalException
from dbt.exceptions import InternalException, CompilationException
from dbt.contracts.util import Replaceable, list_str
from dbt import hooks
from dbt.node_types import NodeType
@@ -204,6 +204,35 @@ class BaseConfig(
else:
self._extra[key] = value
# TODO: uncommenting this fixes test
# def __delitem__(self, key):
# if hasattr(self, key):
# msg = (
# 'Error, tried to delete config key "{}": Cannot delete '
# 'built-in keys'
# ).format(key)
# raise CompilationException(msg)
# else:
# del self._extra[key]
# def _content_iterator(self, include_condition: Callable[[Field], bool]):
# seen = set()
# for fld, _ in self._get_fields():
# seen.add(fld.name)
# if include_condition(fld):
# yield fld.name
# for key in self._extra:
# if key not in seen:
# seen.add(key)
# yield key
# def __iter__(self):
# yield from self._content_iterator(include_condition=lambda f: True)
# def __len__(self):
# return len(self._get_fields()) + len(self._extra)
@staticmethod
def compare_key(
unrendered: Dict[str, Any],

View File

@@ -4,7 +4,7 @@
{%- if custom_alias_name is none -%}
{{ node.name }}
{%- else -%}
custom_{{ node.config['alias'] | trim }}
custom_{{ node.config['alias'] if 'alias' in node.config else '' | trim }}
{%- endif -%}
{%- endmacro %}