Skip to content

Commit

Permalink
Create LogNodeResult event (#11195)
Browse files Browse the repository at this point in the history
* Create LogNodeResult event

* add msg directly during object creation
  • Loading branch information
aranke authored Jan 8, 2025
1 parent 892c545 commit dcc9a0c
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 302 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20250107-205838.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Create LogNodeResult event
time: 2025-01-07T20:58:38.821036Z
custom:
Author: aranke
Issue: ' '
17 changes: 16 additions & 1 deletion core/dbt/events/core_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1355,8 +1355,23 @@ message LogTestResultMsg {
LogTestResult data = 2;
}

// Q008
message LogNodeResult {
NodeInfo node_info = 1;
string description = 2;
string status = 3;
int32 index = 4;
int32 total = 5;
float execution_time = 6;
string msg = 7;
}

message LogNodeResultMsg {
CoreEventInfo info = 1;
LogNodeResult data = 2;
}

// Skipped Q008, Q009, Q010
// Skipped Q009, Q010


// Q011
Expand Down
594 changes: 294 additions & 300 deletions core/dbt/events/core_types_pb2.py

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,15 @@ def status_to_level(cls, status):
return EventLevel.INFO


# Skipped Q008, Q009, Q010
class LogNodeResult(DynamicLevel):
def code(self) -> str:
return "Q008"

def message(self) -> str:
return self.msg


# Skipped Q009, Q010


class LogStartLine(InfoLevel):
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/events/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dbt.adapters.events.types import PluginLoadError, RollbackFailed
from dbt.events import core_types_pb2
from dbt.events.types import (
LogNodeResult,
LogStartLine,
LogTestResult,
MainEncounteredError,
Expand Down Expand Up @@ -185,3 +186,17 @@ def test_dynamic_level_events():
msg = msg_from_base_event(event, level=EventLevel.INFO)
assert msg
assert msg.info.level == "info"


def test_log_node_result():
event = LogNodeResult(
node_info={},
status="error",
index=1,
total=0,
msg="some message",
)
msg = msg_from_base_event(event, level=EventLevel.ERROR)
assert msg
assert msg.info.msg == "some message"
assert msg.info.level == "error"
8 changes: 8 additions & 0 deletions tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ def test_event_codes(self):
execution_time=0,
num_failures=0,
),
core_types.LogNodeResult(
description="",
status="",
index=0,
total=0,
execution_time=0,
msg="",
),
core_types.LogStartLine(description="", index=0, total=0),
core_types.LogModelResult(
description="",
Expand Down

0 comments on commit dcc9a0c

Please sign in to comment.