ashb commented on a change in pull request #9973:
URL: https://github.com/apache/airflow/pull/9973#discussion_r817807948
##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -1580,14 +1581,24 @@ def _create_dag_runs(self, dag_models:
Iterable[DagModel], session: Session) ->
# as DagModel.dag_id and DagModel.next_dagrun
# This list is used to verify if the DagRun already exist so that we
don't attempt to create
# duplicate dag runs
- active_dagruns = (
- session.query(DagRun.dag_id, DagRun.execution_date)
- .filter(
- tuple_(DagRun.dag_id, DagRun.execution_date).in_(
- [(dm.dag_id, dm.next_dagrun) for dm in dag_models]
- )
+
+ if session.bind.dialect.name == 'mssql':
+ active_dagruns_filter = or_(
+ *[
+ and_(
+ DagRun.dag_id == dm.dag_id,
+ DagRun.execution_date == dm.next_dagrun,
+ )
+ for dm in dag_models
+ ]
)
- .all()
+ else:
+ active_dagruns_filter = tuple_(DagRun.dag_id,
DagRun.execution_date).in_(
+ [(dm.dag_id, dm.next_dagrun) for dm in dag_models]
+ )
+
+ active_dagruns = (
Review comment:
Good idea. Feel free to give it a shot if you like :)
--
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]