Skip to content

Commit

Permalink
Fix Query Timer Resolution (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterallenwebb authored Jun 21, 2024
1 parent 267cf5e commit e964302
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240621-150837.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Fix query timer resolution
time: 2024-06-21T15:08:37.43527-04:00
custom:
Author: peterallenwebb
Issue: "246"
2 changes: 1 addition & 1 deletion dbt/adapters/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def code(self) -> str:
return "E017"

def message(self) -> str:
return f"SQL status: {self.status} in {self.elapsed} seconds"
return f"SQL status: {self.status} in {self.elapsed:.3f} seconds"


class SQLCommit(DebugLevel):
Expand Down
5 changes: 3 additions & 2 deletions dbt/adapters/sql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,16 @@ def add_query(
node_info=get_node_info(),
)
)
pre = time.time()

pre = time.perf_counter()

cursor = connection.handle.cursor()
cursor.execute(sql, bindings)

fire_event(
SQLQueryStatus(
status=str(self.get_response(cursor)),
elapsed=round((time.time() - pre)),
elapsed=time.perf_counter() - pre,
node_info=get_node_info(),
)
)
Expand Down

0 comments on commit e964302

Please sign in to comment.