Skip to content

Commit

Permalink
made process more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop committed Dec 2, 2021
1 parent e9212f2 commit 0d81c2c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion core/dbt/adapters/sql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def add_query(

fire_event(
SQLQueryStatus(
status=str(self.get_response(cursor)), elapsed=round((time.time() - pre), 2)
status=self.get_response(cursor)._message, elapsed=round((time.time() - pre), 2)
)
)

Expand Down
2 changes: 1 addition & 1 deletion core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def message(self) -> str:

@dataclass
class SQLQueryStatus(DebugLevel, Cli, File):
status: str # could include AdapterResponse if we resolve circular imports
status: str
elapsed: float
code: str = "E017"

Expand Down
12 changes: 4 additions & 8 deletions core/dbt/task/freshness.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ def after_execute(self, result):
table_name=table_name,
index=self.node_index,
total=self.num_nodes,
execution_time=result.execution_time,
report_node_data=self.node
execution_time=result.execution_time
)
)
elif result.status == FreshnessStatus.Error:
Expand All @@ -70,8 +69,7 @@ def after_execute(self, result):
table_name=table_name,
index=self.node_index,
total=self.num_nodes,
execution_time=result.execution_time,
report_node_data=self.node
execution_time=result.execution_time
)
)
elif result.status == FreshnessStatus.Warn:
Expand All @@ -81,8 +79,7 @@ def after_execute(self, result):
table_name=table_name,
index=self.node_index,
total=self.num_nodes,
execution_time=result.execution_time,
report_node_data=self.node
execution_time=result.execution_time
)
)
else:
Expand All @@ -92,8 +89,7 @@ def after_execute(self, result):
table_name=table_name,
index=self.node_index,
total=self.num_nodes,
execution_time=result.execution_time,
report_node_data=self.node
execution_time=result.execution_time
)
)

Expand Down
9 changes: 5 additions & 4 deletions core/dbt/task/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,13 @@ def run_hooks(self, adapter, hook_type: RunHookType, extra_context):
)
)

status = 'OK'

with Timer() as timer:
if len(sql.strip()) > 0:
status, _ = adapter.execute(sql, auto_begin=False,
response, _ = adapter.execute(sql, auto_begin=False,
fetch=False)
status = response._message
else:
status = 'OK'

self.ran_hooks.append(hook)
hook._event_status['finished_at'] = datetime.utcnow().isoformat()
Expand All @@ -376,7 +377,7 @@ def run_hooks(self, adapter, hook_type: RunHookType, extra_context):
fire_event(
PrintHookEndLine(
statement=hook_text,
status=str(status),
status=status,
index=idx,
total=num_hooks,
execution_time=timer.elapsed,
Expand Down

0 comments on commit 0d81c2c

Please sign in to comment.