uranusjr commented on code in PR #30117:
URL: https://github.com/apache/airflow/pull/30117#discussion_r1139924860
##########
airflow/cli/commands/dag_command.py:
##########
@@ -294,38 +294,46 @@ def dag_next_execution(args):
if dag.get_is_paused():
print("[INFO] Please be reminded this DAG is PAUSED now.",
file=sys.stderr)
+ with create_session() as session:
+ last_parsed_dag: DagModel = (
+ session.query(DagModel).filter(DagModel.dag_id == dag.dag_id)
+ ).one_or_none()
+ print(last_parsed_dag.next_dagrun.isoformat())
+ else:
+ with create_session() as session:
+ max_date_subq = (
+
session.query(func.max(DagRun.execution_date).label("max_date"))
+ .filter(DagRun.dag_id == dag.dag_id)
+ .subquery()
+ )
+ max_date_run: DagRun | None = (
+ session.query(DagRun)
+ .filter(DagRun.dag_id == dag.dag_id, DagRun.execution_date ==
max_date_subq.c.max_date)
+ .one_or_none()
+ )
Review Comment:
From what I can tell, lines below here should all be outside of the `with
create_session()` block.
--
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]