Skip to content

Commit

Permalink
Fix yaml snapshot specification with data tests (#11156)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6076cf7)
  • Loading branch information
gshank authored and github-actions[bot] committed Dec 18, 2024
1 parent 75aeafe commit 4a05246
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241216-134645.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Error writing generic test at run time
time: 2024-12-16T13:46:45.936573-05:00
custom:
Author: gshank
Issue: "11110"
9 changes: 8 additions & 1 deletion core/dbt/parser/schemas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import pathlib
import time
from abc import ABCMeta, abstractmethod
from dataclasses import dataclass, field
Expand Down Expand Up @@ -289,9 +290,15 @@ def _add_yaml_snapshot_nodes_to_manifest(
parser = SnapshotParser(self.project, self.manifest, self.root_project)
fqn = parser.get_fqn_prefix(block.path.relative_path)
fqn.append(snapshot["name"])

compiled_path = str(

Check warning on line 294 in core/dbt/parser/schemas.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/parser/schemas.py#L294

Added line #L294 was not covered by tests
pathlib.PurePath("").joinpath(
block.path.relative_path, snapshot["name"] + ".sql"
)
)
snapshot_node = parser._create_parsetime_node(
block,
self.get_compiled_path(block),
compiled_path,
parser.initial_config(fqn),
fqn,
snapshot["name"],
Expand Down
8 changes: 8 additions & 0 deletions tests/functional/snapshots/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@
updated_at: updated_at
meta:
owner: 'a_owner'
columns:
- name: id
data_tests:
- not_null
"""

snapshots_pg__snapshot_mod_yml = """
Expand All @@ -313,6 +317,10 @@
updated_at: updated_at
meta:
owner: 'b_owner'
columns:
- name: id
data_tests:
- not_null
"""

snapshots_pg__snapshot_no_target_schema_sql = """
Expand Down

0 comments on commit 4a05246

Please sign in to comment.