From 0d81c2ca3a3e35003d6dfe3747d1efd61de2463d Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Thu, 2 Dec 2021 08:50:51 -0600 Subject: [PATCH] made process more clear --- core/dbt/adapters/sql/connections.py | 2 +- core/dbt/events/types.py | 2 +- core/dbt/task/freshness.py | 12 ++++-------- core/dbt/task/run.py | 9 +++++---- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/core/dbt/adapters/sql/connections.py b/core/dbt/adapters/sql/connections.py index 654628b1342..1f9fe35320b 100644 --- a/core/dbt/adapters/sql/connections.py +++ b/core/dbt/adapters/sql/connections.py @@ -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) ) ) diff --git a/core/dbt/events/types.py b/core/dbt/events/types.py index 536d7e92fc2..8521c1226a9 100644 --- a/core/dbt/events/types.py +++ b/core/dbt/events/types.py @@ -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" diff --git a/core/dbt/task/freshness.py b/core/dbt/task/freshness.py index 5edb7b476ca..096578d9a15 100644 --- a/core/dbt/task/freshness.py +++ b/core/dbt/task/freshness.py @@ -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: @@ -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: @@ -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: @@ -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 ) ) diff --git a/core/dbt/task/run.py b/core/dbt/task/run.py index 5a5a6950543..41d58958b62 100644 --- a/core/dbt/task/run.py +++ b/core/dbt/task/run.py @@ -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() @@ -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,