jason810496 commented on code in PR #52325:
URL: https://github.com/apache/airflow/pull/52325#discussion_r2313784691


##########
providers/common/io/tests/unit/common/io/xcom/test_backend.py:
##########
@@ -129,7 +135,25 @@ def test_value_storage(self, task_instance, 
mock_supervisor_comms, session):
             run_id=task_instance.run_id,
         )
 
-        if AIRFLOW_V_3_0_PLUS:
+        if AIRFLOW_V_3_1_PLUS:
+            XComModel.set(
+                key=XCOM_RETURN_KEY,
+                value=self.path,
+                dag_id=task_instance.dag_id,
+                task_id=task_instance.task_id,
+                run_id=task_instance.run_id,
+            )
+
+            res = session.execute(
+                XComModel.get_many(
+                    key=XCOM_RETURN_KEY,
+                    dag_ids=task_instance.dag_id,
+                    task_ids=task_instance.task_id,
+                    run_id=task_instance.run_id,
+                ).with_only_columns(XComModel.value)
+            ).first()
+            data = XComModel.deserialize_value(res)

Review Comment:
   The compatible test can be simplified as somehow like:  
   
   ```python
   
   if AIRFLOW_V_3_0_PLUS:
       XComModel.set(
           key=XCOM_RETURN_KEY,
           value=self.path,
           dag_id=task_instance.dag_id,
           task_id=task_instance.task_id,
           run_id=task_instance.run_id,
       )
       
       if AIRFLOW_V_3_1_PLUS:
             res = session.execute(
                 XComModel.get_many(
                     key=XCOM_RETURN_KEY,
                     dag_ids=task_instance.dag_id,
                     task_ids=task_instance.task_id,
                     run_id=task_instance.run_id,
                 ).with_only_columns(XComModel.value)
             ).first()
       else:
             res = (
                 XComModel.get_many(
                     key=XCOM_RETURN_KEY,
                     dag_ids=task_instance.dag_id,
                     task_ids=task_instance.task_id,
                     run_id=task_instance.run_id,
                     session=session,
                 )
                 .with_entities(XComModel.value)
                 .first()
             )
       data = XComModel.deserialize_value(res)
   ```
   
   Additionally we can even add a new test method for using 
`XComModel.get_many` with compact.
   Maybe like
   
   ```python
   
   def _xcom_model_get_many(self, session, key .. ):
       if AIRFLOW_V_3_1_PLUS:
            session.execute(
                 XComModel.get_many( ...
       else:
           XComModel.get_many( ...
   ```



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