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 query_id as optional to SQLQueryStatus #333

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't protobuf fields optional by default?

}

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
Loading