You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/06/20 07:47:45 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #32009: Fix ExternalTaskSensor when there is not task group TIs for the current execution date

uranusjr commented on code in PR #32009:
URL: https://github.com/apache/airflow/pull/32009#discussion_r1234874219


##########
airflow/sensors/external_task.py:
##########
@@ -367,10 +367,15 @@ def get_count(self, dttm_filter, session, states) -> int:
         elif self.external_task_group_id:
             external_task_group_task_ids = self.get_external_task_group_task_ids(session, dttm_filter)
             count = (
-                self._count_query(TI, session, states, dttm_filter)
-                .filter(tuple_in_condition((TI.task_id, TI.map_index), external_task_group_task_ids))
-                .scalar()
-            ) / len(external_task_group_task_ids)
+                0
+                if not external_task_group_task_ids
+                else (
+                    self._count_query(TI, session, states, dttm_filter)
+                    .filter(tuple_in_condition((TI.task_id, TI.map_index), external_task_group_task_ids))
+                    .scalar()
+                )
+                / len(external_task_group_task_ids)
+            )

Review Comment:
   This is a bit too complicated, let’s use the good old if-else blocks here.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org