Skip to content

Commit

Permalink
fix: Log athena query id when it is available. Closes #530
Browse files Browse the repository at this point in the history
- Log the query id as soon as it is available
- Adds query_id to warning and debug logs in AthenaCursor
  • Loading branch information
WarFox committed Dec 10, 2023
1 parent bae9fce commit e4f7acc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dbt/adapters/athena/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _poll(self, query_id: str) -> AthenaQueryExecution:
query_execution = self.__poll(query_id)
except KeyboardInterrupt as e:
if self._kill_on_interrupt:
logger.warning("Query canceled by user.")
logger.warning(f"Query canceled by user: {query_id}.")
self._cancel(query_id)
query_execution = self.__poll(query_id)
else:
Expand All @@ -139,7 +139,9 @@ def __poll(self, query_id: str) -> AthenaQueryExecution:
return query_execution

if self.connection.cursor_kwargs.get("debug_query_state", False):
logger.debug(f"Query state is: {query_execution.state}. Sleeping for {self._poll_interval}...")
logger.debug(
f"Query state for {query_id} is: {query_execution.state}. Sleeping for {self._poll_interval}..."
)
time.sleep(self._poll_interval)

def execute( # type: ignore
Expand All @@ -163,6 +165,9 @@ def inner() -> AthenaCursor:
cache_size=cache_size,
cache_expiration_time=cache_expiration_time,
)

logger.debug(f"Athena query ID {query_id}")

query_execution = self._executor.submit(self._collect_result_set, query_id).result()
if query_execution.state == AthenaQueryExecution.STATE_SUCCEEDED:
self.result_set = self._result_set_class(
Expand Down

0 comments on commit e4f7acc

Please sign in to comment.