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

Ensure meta is both at node top level and in node.config. Fix snapshots with schema config. #4726

Merged
merged 7 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## dbt-core 1.1.0 (TBD)

## dbt-core 1.0.3 (TBD)

### Fixes
- Fix bug causing empty node level meta, snapshot config errors ([#4459](https://github.com/dbt-labs/dbt-core/issues/4459), [#4726](https://github.com/dbt-labs/dbt-core/pull/4726))

### Features
- Added Support for Semantic Versioning ([#4644](https://github.com/dbt-labs/dbt-core/pull/4644))
- New Dockerfile to support specific db adapters and platforms. See docker/README.md for details ([#4495](https://github.com/dbt-labs/dbt-core/issues/4495), [#4487](https://github.com/dbt-labs/dbt-core/pull/4487))
Expand Down
1 change: 0 additions & 1 deletion core/dbt/contracts/graph/parsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def patch(self, patch: "ParsedNodePatch"):
self.created_at = time.time()
self.description = patch.description
self.columns = patch.columns
self.meta = patch.meta
self.docs = patch.docs

def get_materialization(self):
Expand Down
6 changes: 6 additions & 0 deletions core/dbt/parser/snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ def get_fqn(self, path: str, name: str) -> List[str]:

def transform(self, node: IntermediateSnapshotNode) -> ParsedSnapshotNode:
try:
# The config_call_dict is not serialized, because normally
# it is not needed after parsing. But since the snapshot node
# does this extra to_dict, save and restore it, to keep
# the model config when there is also schema config.
config_call_dict = node.config_call_dict
dct = node.to_dict(omit_none=True)
parsed_node = ParsedSnapshotNode.from_dict(dct)
parsed_node.config_call_dict = config_call_dict
self.set_snapshot_attributes(parsed_node)
return parsed_node
except ValidationError as exc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ snapshots:
- name: snapshot_actual
tests:
- mutually_exclusive_ranges
config:
meta:
owner: 'a_owner'
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def test_postgres_config_layering(self):
manifest = get_manifest()
model_id = 'model.test.model'
model_node = manifest.nodes[model_id]
meta_expected = {'company': 'NuMade', 'project': 'test', 'team': 'Core Team', 'owner': 'Julie Smith', 'my_attr': 'TESTING'}
self.assertEqual(model_node.meta, meta_expected)
self.assertEqual(model_node.config.meta, meta_expected)
model_tags = ['tag_1_in_model', 'tag_2_in_model', 'tag_in_project', 'tag_in_schema']
model_node_tags = model_node.tags.copy()
model_node_tags.sort()
Expand Down