steveahnahn commented on code in PR #68423: URL: https://github.com/apache/airflow/pull/68423#discussion_r3407553161
########## airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py: ########## @@ -79,6 +80,23 @@ DEFAULT_RENDERED_MAP_INDEX = "test rendered map index" [email protected] +def _capture_task_instance_selects(session): + statements = [] + + def collect_selects(conn, cursor, statement, parameters, context, executemany): + normalized = " ".join(statement.lower().split()) + if normalized.startswith("select") and " from task_instance" in normalized: Review Comment: Tightened this to `re.search(r"\bfrom task_instance\b", normalized)` so the helper only counts selects from the `task_instance` table. ########## airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py: ########## @@ -1163,9 +1156,13 @@ def get_task_instance_states( run_id_task_state_map: dict[str, dict[str, Any]] = defaultdict(dict) query = select(TI).where(TI.dag_id == dag_id) + selected_task_ids = list(task_ids or []) - if task_ids: - query = query.where(TI.task_id.in_(task_ids)) + if task_group_id: + selected_task_ids.extend(_get_group_task_ids(dag_id, task_group_id, session, dag_bag)) + + if selected_task_ids or task_group_id: Review Comment: Added a short comment above this predicate to document why `task_group_id` stays load-bearing when the resolved task list is empty. -- 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]
