bryanyang0528 commented on a change in pull request #4919: [AIRFLOW-4093] Add
exception if job failed or cancelled or retry too many times
URL: https://github.com/apache/airflow/pull/4919#discussion_r265861330
##########
File path: airflow/contrib/hooks/aws_athena_hook.py
##########
@@ -127,14 +127,21 @@ def poll_query_status(self, query_execution_id,
max_tries=None):
elif query_state in self.INTERMEDIATE_STATES:
self.log.info('Trial {try_number}: Query is still in an
intermediate state - {state}'
.format(try_number=try_number,
state=query_state))
+ elif query_state in self.FAILURE_STATES:
+ self.log.error('Trial {try_number}: Query is failed - {state}'
+ .format(try_number=try_number,
state=query_state))
+ raise Exception('Athena job
{state}.'.format(state=query_state))
else:
self.log.info('Trial {try_number}: Query execution completed.
Final state is {state}'
.format(try_number=try_number,
state=query_state))
final_query_state = query_state
break
Review comment:
https://github.com/apache/airflow/blob/17eb94f723502d8bbc716763a7513db0a8afa52d/airflow/contrib/hooks/bigquery_hook.py#L1248
I take `bigquery_hook` as a reference. If the query failed and return the
state to Athena Operator, the query job won't be failed and will trigger the
downstream job. That's why I would like to add an Exception if the query failed.
Instead of breaking the logic of `pull_query_status()`, I can add the
exception in the `AWSAthenaOperator`. Which one will you suggest?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services