Lee-W commented on code in PR #59973:
URL: https://github.com/apache/airflow/pull/59973#discussion_r2660867164
##########
airflow-core/tests/unit/models/test_log.py:
##########
@@ -0,0 +1,66 @@
+from __future__ import annotations
+
+import pytest
+
+from airflow.models.log import Log
+from airflow.operators.empty import EmptyOperator
+from airflow.utils.state import TaskInstanceState
+
+pytestmark = pytest.mark.db_test
+
+class TestLogTaskInstanceReproduction:
+ def test_log_task_instance_join_correctness(self, dag_maker, session):
+ # Create dag_1 with a task
+ with dag_maker("dag_1", session=session):
+ EmptyOperator(task_id="common_task_id")
+
+ dr1 = dag_maker.create_dagrun()
+ ti1 = dr1.get_task_instance("common_task_id")
+ ti1.state = TaskInstanceState.SUCCESS
+ session.merge(ti1)
+ session.commit()
+
+ # Create dag_2 with the SAME task_id
+ with dag_maker("dag_2", session=session):
+ EmptyOperator(task_id="common_task_id")
+
+ dr2 = dag_maker.create_dagrun()
+ ti2 = dr2.get_task_instance("common_task_id")
+ ti2.state = TaskInstanceState.FAILED
+ session.merge(ti2)
+ session.commit()
+
+ # Create a log entry specifically for dag_1's task instance
+ log = Log(
+ event="test_event",
+ task_instance=ti1,
+ )
+ session.add(log)
+ session.commit()
+
+ # Query with joinedload to trigger the relationship join
+ from sqlalchemy import select
Review Comment:
Why do we need to import them here? Should we move them to the top?
##########
airflow-core/tests/unit/models/test_log.py:
##########
@@ -0,0 +1,66 @@
+from __future__ import annotations
Review Comment:
We need license 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]