Skip to content

Commit

Permalink
add query_id as optional to SQLQueryStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcarthur committed Oct 30, 2024
1 parent b12c987 commit 26a01a8
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 104 deletions.
1 change: 1 addition & 0 deletions dbt/adapters/contracts/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AdapterResponse(dbtClassMixin):
_message: str
code: Optional[str] = None
rows_affected: Optional[int] = None
query_id: Optional[str] = None

def __str__(self):
return self._message
Expand Down
1 change: 1 addition & 0 deletions dbt/adapters/events/adapter_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ message SQLQueryStatus {
AdapterNodeInfo node_info = 1;
string status = 2;
float elapsed = 3;
optional string query_id = 4;
}

message SQLQueryStatusMsg {
Expand Down
207 changes: 104 additions & 103 deletions dbt/adapters/events/adapter_types_pb2.py

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion dbt/adapters/sql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ def add_query(
cursor = connection.handle.cursor()
cursor.execute(sql, bindings)

result = self.get_response(cursor)

fire_event(
SQLQueryStatus(
status=str(self.get_response(cursor)),
status=str(result),
elapsed=time.perf_counter() - pre,
node_info=get_node_info(),
query_id=result.query_id,
)
)

Expand Down

0 comments on commit 26a01a8

Please sign in to comment.