mik-laj commented on pull request #9170:
URL: https://github.com/apache/airflow/pull/9170#issuecomment-641653054


   @ashb It looks good, but I don't know if it suits our code style.  We use 
explicit joins instead of relying on ORM generated more often. Generating 
joints by ORM together with the use of multi-column primary keys can lead to 
spaghetti. Each model will have a relationship with each model because many 
values are repeated.  We only use ORM-based relationships in one place - 
DagModel.tags   It fits here because we can easily retrieve the 
object(DagModel) and metadata. (DagTag).  In other places, we need careful 
control to ensure good performance.
   
   I also prepared an example.
   
https://github.com/apache/airflow/pull/9170/commits/16f829927859604336013dd7a9755fcf7000f786
   ```python
       query = session.query(XCom)
       query = query.filter(and_(XCom.dag_id == dag_id,
                                 XCom.task_id == task_id,
                                 XCom.key == xcom_key))
       query = query.join(DR, and_(XCom.dag_id == DR.dag_id, 
XCom.execution_date == DR.execution_date))
       query = query.filter(DR.run_id == dag_run_id)
   
       q_object = query.one_or_none()
   ```
   


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


Reply via email to