Skip to content

Commit

Permalink
Ensure meta is both at node top level and in node.config. Fix snapsho…
Browse files Browse the repository at this point in the history
…ts with schema config. (dbt-labs#4726)

* Do not overwrite node.meta with empty patch.meta

* Restore config_call_dict in snapshot node transform

* Test for snapshot with schema file config

* Test for meta in both toplevel node and node config
  • Loading branch information
gshank authored and sp-tim committed Feb 21, 2022
1 parent b3a4ccb commit 320089d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
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
3 changes: 3 additions & 0 deletions test/integration/004_simple_snapshot_tests/models/schema.yml
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

0 comments on commit 320089d

Please sign in to comment.