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

Add meta config to test log messages #10812

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241002-155726.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix missing meta config in test log messages
time: 2024-10-02T15:57:26.594034+01:00
custom:
Author: tomwphillips
Issue: "10811"
1 change: 1 addition & 0 deletions core/dbt/parser/schema_generic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def get_hashable_md(data: Union[str, int, float, List, Dict]) -> Union[str, List
"column_name": column_name,
"checksum": FileHash.empty().to_dict(omit_none=True),
"file_key_name": file_key_name,
"meta": target.config.get("meta", {}) if hasattr(target, "config") else {},
}
try:
GenericTestNode.validate(dct)
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/artifacts/expected_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ def expected_versions_manifest(project):
"schema": test_audit_schema,
"database": project.database,
"tags": [],
"meta": {},
"meta": {"size": "large", "color": "blue"},
"unique_id": "test.test.unique_versioned_model_v1_first_name.6138195dec",
"docs": {"node_color": None, "show": True},
"compiled": True,
Expand Down Expand Up @@ -1813,7 +1813,7 @@ def expected_versions_manifest(project):
"schema": test_audit_schema,
"database": project.database,
"tags": [],
"meta": {},
"meta": {"color": "blue", "size": "large"},
"unique_id": "test.test.unique_versioned_model_v1_count.0b4c0b688a",
"docs": {"node_color": None, "show": True},
"compiled": True,
Expand Down Expand Up @@ -1866,7 +1866,7 @@ def expected_versions_manifest(project):
"schema": test_audit_schema,
"database": project.database,
"tags": [],
"meta": {},
"meta": {"color": "blue", "size": "large"},
"unique_id": "test.test.unique_versioned_model_v2_first_name.998430d28e",
"docs": {"node_color": None, "show": True},
"compiled": True,
Expand Down
27 changes: 27 additions & 0 deletions tests/functional/logging/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,30 @@ def test_node_info_on_results(self, project, logs_dir):
run_result_warning_count += 1

assert run_result_warning_count == 1


class TestRunResultMeta:
@pytest.fixture(scope="class")
def models(self):
model_config = """
models:
- name: my_model
meta:
owner: analytics
columns:
- name: id
tests:
- not_null
"""
return {"my_model.sql": "select null as id", "models.yml": model_config}

def test_test_failures_include_meta_from_model_config(self, project, logs_dir):
results = run_dbt(["--log-format=json", "build"], expect_pass=False)
assert len(results) == 2

log_file = read_file(logs_dir, "dbt.log")
messages = [json.loads(line) for line in log_file.split("\n") if line]
[
test_result,
] = [message for message in messages if message["info"]["name"] == "LogTestResult"]
assert test_result["data"]["node_info"]["meta"] == {"owner": "analytics"}
Loading