diff --git a/core/dbt/parser/schema_generic_tests.py b/core/dbt/parser/schema_generic_tests.py index 14e2dbc862a..1200d2c6723 100644 --- a/core/dbt/parser/schema_generic_tests.py +++ b/core/dbt/parser/schema_generic_tests.py @@ -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) diff --git a/tests/functional/logging/test_logging.py b/tests/functional/logging/test_logging.py index e29bd9c7cac..29029b085af 100644 --- a/tests/functional/logging/test_logging.py +++ b/tests/functional/logging/test_logging.py @@ -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"}