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/22 08:53:32 UTC

[GitHub] [airflow] houqp edited a comment on pull request #11621: Make DagRunType inherit from `str` too for easier use.

houqp edited a comment on pull request #11621:
URL: https://github.com/apache/airflow/pull/11621#issuecomment-749426713


   @ashb did you test this with mysql as well? I am trying figure out whether I am missing something in my mysql config. When the enum type used in sqlalchemy query, it's being resolved into `'DagRunType.SCHEDULED'` not `'scheduled'`. I am able to reproduce this in breeze with the following code:
   
   ```
   from sqlalchemy import Boolean, Column, ForeignKey, Index, Integer, String, Text, func, or_
   from airflow.models.dagrun import DagRun
   from airflow.utils.types import DagRunType
   from airflow.utils.session import create_session
   
   with create_session() as session:
       q1 = session.query(
               DagRun.dag_id, func.max_(DagRun.execution_date),
       ).filter(
           DagRun.run_type == DagRunType.SCHEDULED,
       ).group_by(DagRun.dag_id)
       q.all()
   ```
   
   Running this script with strace shows that sqlalchemy sent `'DagRunType.SCHEDULED'` to the mysql server instead of `'scheduled'`. Here is the output from strace (`strace -v -s 1024 -e trace=sendto python a.py`):
   
   ```
   sendto(3, "\314\0\0\0\3SELECT dag_run.dag_id AS dag_run_dag_id, max(dag_run.execution_date) AS max_1 \nFROM dag_run \nWHERE dag_run.run_type = 'DagRunType.SCHEDULED' GROUP BY dag_run.dag_id", 208, 0, NULL, 0) = 208
   ```
   
   Using `DagRunType.SCHEDULED.value` in the query fixes the error.


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