guan404ming commented on code in PR #55160:
URL: https://github.com/apache/airflow/pull/55160#discussion_r2353160376


##########
airflow-core/src/airflow/models/log.py:
##########
@@ -56,6 +56,14 @@ class Log(Base):
         primaryjoin="Log.dag_id == DagModel.dag_id",
     )
 
+    task_instance = relationship(
+        "TaskInstance",
+        viewonly=True,
+        foreign_keys=[task_id],
+        primaryjoin="Log.task_id == TaskInstance.task_id",
+        lazy="selectin",
+    )
+

Review Comment:
   Thanks for the feedback!
   I’d prefer not to remove the relationship because it’s useful to keep it 
defined at the model level — it makes the schema explicit, provides type 
hints/IDE support, and simplifies queries where we actually need to join 
TaskInstance.
   
   To avoid the side effect of preloading TIs for every Log query (like in the 
scheduler), I think we could switch to lazy="noload". That way the relationship 
is still available for use, but it won’t be auto-loaded unless explicitly 
requested (e.g., in the get_logs endpoint with .options(...)). Would that 
address the concern?



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