You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/12/08 09:45:29 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #12905: Make xcom_pull results order deterministic

turbaszek commented on a change in pull request #12905:
URL: https://github.com/apache/airflow/pull/12905#discussion_r538187718



##########
File path: airflow/models/taskinstance.py
##########
@@ -1883,16 +1883,24 @@ def xcom_pull(  # pylint: disable=inconsistent-return-statements
             task_ids=task_ids,
             include_prior_dates=include_prior_dates,
             session=session,
-        ).with_entities(XCom.value)
+        )
 
         # Since we're only fetching the values field, and not the
         # whole class, the @recreate annotation does not kick in.
         # Therefore we need to deserialize the fields by ourselves.
-
         if is_container(task_ids):
-            return [XCom.deserialize_value(xcom) for xcom in query]
+            vals_kv = {
+                result.task_id: XCom.deserialize_value(result)
+                for result in query.with_entities(XCom.task_id, XCom.value)
+            }
+
+            vals = []
+            for task_id in task_ids:
+                vals.append(vals_kv.get(task_id))
+
+            return vals

Review comment:
       ```suggestion
               values_ordered_by_id = [vals_kv.get(task_id) for task_id in task_ids]
               return values_ordered_by_id
   ```




----------------------------------------------------------------
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:
users@infra.apache.org