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

Refactor get_output_location method in AthenaHook #35996

Merged
Merged
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
8 changes: 2 additions & 6 deletions airflow/providers/amazon/aws/hooks/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,24 +292,20 @@ def get_output_location(self, query_execution_id: str) -> str:

:param query_execution_id: Id of submitted athena query
"""
output_location = None
if query_execution_id:
response = self.get_query_info(query_execution_id=query_execution_id, use_cache=True)

if response:
try:
output_location = response["QueryExecution"]["ResultConfiguration"]["OutputLocation"]
return response["QueryExecution"]["ResultConfiguration"]["OutputLocation"]
except KeyError:
self.log.error(
"Error retrieving OutputLocation. Query execution id: %s", query_execution_id
)
raise
else:
raise
else:
raise ValueError("Invalid Query execution id. Query execution id: %s", query_execution_id)

return output_location
raise ValueError("Invalid Query execution id. Query execution id: %s", query_execution_id)

def stop_query(self, query_execution_id: str) -> dict:
"""Cancel the submitted query.
Expand Down