From 5fbb833898cd4258722bb02a0947e7d7b1571ad9 Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Tue, 24 Jan 2023 14:25:32 -0500 Subject: [PATCH] CT 1886 include adapter_response in NodeFinished log message (#6709) * Include adapter_response in run_result in NodeFinished log event * Changie (cherry picked from commit e2ccf011d98a055c3ce1805ecbdc4740ffc99041) --- .changes/unreleased/Fixes-20230124-115837.yaml | 6 ++++++ core/dbt/contracts/results.py | 5 ++--- tests/functional/logging/test_logging.py | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Fixes-20230124-115837.yaml diff --git a/.changes/unreleased/Fixes-20230124-115837.yaml b/.changes/unreleased/Fixes-20230124-115837.yaml new file mode 100644 index 00000000000..c74e83bbaf0 --- /dev/null +++ b/.changes/unreleased/Fixes-20230124-115837.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Include adapter_response in NodeFinished run_result log event +time: 2023-01-24T11:58:37.74179-05:00 +custom: + Author: gshank + Issue: "6703" diff --git a/core/dbt/contracts/results.py b/core/dbt/contracts/results.py index 9243750284f..4378d207ac2 100644 --- a/core/dbt/contracts/results.py +++ b/core/dbt/contracts/results.py @@ -13,7 +13,7 @@ from dbt.events.proto_types import RunResultMsg, TimingInfoMsg from dbt.events.contextvars import get_node_info from dbt.logger import TimingProcessor -from dbt.utils import lowercase, cast_to_str, cast_to_int +from dbt.utils import lowercase, cast_to_str, cast_to_int, cast_dict_to_dict_of_strings from dbt.dataclass_schema import dbtClassMixin, StrEnum import agate @@ -130,7 +130,6 @@ def __pre_deserialize__(cls, data): return data def to_msg(self): - # TODO: add more fields msg = RunResultMsg() msg.status = str(self.status) msg.message = cast_to_str(self.message) @@ -138,7 +137,7 @@ def to_msg(self): msg.execution_time = self.execution_time msg.num_failures = cast_to_int(self.failures) msg.timing_info = [ti.to_msg() for ti in self.timing] - # adapter_response + msg.adapter_response = cast_dict_to_dict_of_strings(self.adapter_response) return msg diff --git a/tests/functional/logging/test_logging.py b/tests/functional/logging/test_logging.py index 863c40f1e7d..9cf50bf73c9 100644 --- a/tests/functional/logging/test_logging.py +++ b/tests/functional/logging/test_logging.py @@ -40,6 +40,7 @@ def test_basic(project, logs_dir): node_start = True if log_event == "NodeFinished": node_finished = True + assert log_data["run_result"]["adapter_response"] if node_start and not node_finished: if log_event == 'NodeExecuting': assert "node_info" in log_data