Used in https://github.com/mhenc/airflow/blob/master/airflow/dag_processing/manager.py#L613

should be straighforward
x.dag_id: {
            "uri": x.uri,
            "ready": x.ready,
            "total": x.total,
        }
        for x in session.query(
            DagScheduleDatasetReference.dag_id,
            
            
            case((func.count() == 1, func.max(DatasetModel.uri)), else_="").label("uri"),
            func.count().label("total"),
            func.sum(case((DDRQ.target_dag_id.is_not(None), 1), else_=0)).label("ready"),
        )
        .join(
            DDRQ,
            and_(
                DDRQ.dataset_id == DagScheduleDatasetReference.dataset_id,
                DDRQ.target_dag_id == DagScheduleDatasetReference.dag_id,
            ),
            isouter=True,
        )
        .join(
            DatasetModel,
            DatasetModel.id == DagScheduleDatasetReference.dataset_id,
        )
        .group_by(
            DagScheduleDatasetReference.dag_id,
        )
        .filter(DagScheduleDatasetReference.dag_id.in_(dag_ids))
        .all()