thesuperzapper commented on code in PR #39442:
URL: https://github.com/apache/airflow/pull/39442#discussion_r1591463675


##########
airflow/providers/google/cloud/triggers/bigquery.py:
##########
@@ -89,6 +108,38 @@ def serialize(self) -> tuple[str, dict[str, Any]]:
             },
         )
 
+    @provide_session
+    def get_task_instance(self, session: Session) -> TaskInstance:
+        """
+        Get the task instance for the current task.
+
+        :param session: Sqlalchemy session
+        """
+        query = session.query(TaskInstance).filter(
+            TaskInstance.dag_id == self.dag_id,
+            TaskInstance.task_id == self.task_id,
+            TaskInstance.run_id == self.run_id,
+        )
+        task_instance = query.one_or_none()
+        if task_instance is None:
+            raise AirflowException(
+                f"TaskInstance {self.dag_id}.{self.task_id} with run_id 
{self.run_id} not found"
+            )

Review Comment:
   My main concerns are around this section.
   
   I am not sure of all the possible cases in the DB, e.g. can there be more 
than one match for this filter query (e.g. mapped tasks)?
   
   And will this filter query definitely find the TaskInstance for the deferred 
operator which is running it?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to