pgagnon commented on a change in pull request #5488: [AIRFLOW-4880] Add
success, failure and fail_on_empty params to SqlSensor
URL: https://github.com/apache/airflow/pull/5488#discussion_r305819513
##########
File path: airflow/sensors/sql_sensor.py
##########
@@ -63,5 +80,15 @@ def poke(self, context):
self.log.info('Poking: %s (with parameters %s)', self.sql,
self.parameters)
records = hook.get_records(self.sql, self.parameters)
if not records:
- return False
- return str(records[0][0]) not in ('0', '')
+ if self.fail_on_empty:
+ raise AirflowException("No rows returned, raising as per
fail_on_empty flag")
+ else:
+ return False
+ first_cell = records[0][0]
+ if isinstance(self.failure, Callable):
Review comment:
You could replace this check with `if callable(self.failure)`.
----------------------------------------------------------------
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