This is an automated email from the ASF dual-hosted git repository.

kaxil pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 943c8ffcebc Stop SQLAlchemy subquery warning when loading the latest 
serialized Dag (#73461)
943c8ffcebc is described below

commit 943c8ffcebced74d5b10ff1eb58ec7fcf2b768f8
Author: Andrii Roiko <[email protected]>
AuthorDate: Fri Nov 20 02:45:31 2026 +0200

    Stop SQLAlchemy subquery warning when loading the latest serialized Dag 
(#73461)
    
    On MySQL deployments every lookup of the latest serialized Dag emits a
    "implicitly coercing SELECT object to scalar subquery" SAWarning, so routine
    operations such as `airflow tasks clear` or opening the grid view spam the
    logs and bury warnings that actually matter. The generated SQL is identical
    either way.
    
    * Turn implicit scalar subquery coercion warning into a test error
    
    Without this the SAWarning only shows up in logs, so a regression in
    the MySQL branch of latest_item_select_object could come back unnoticed.
    Erroring on it makes the MySQL backend tests fail instead, the same way
    the IN() coercion variant is guarded.
---
 airflow-core/src/airflow/models/serialized_dag.py | 2 +-
 pyproject.toml                                    | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/airflow-core/src/airflow/models/serialized_dag.py 
b/airflow-core/src/airflow/models/serialized_dag.py
index 63ca5a7b1e3..9d383e9dc6b 100644
--- a/airflow-core/src/airflow/models/serialized_dag.py
+++ b/airflow-core/src/airflow/models/serialized_dag.py
@@ -847,7 +847,7 @@ class SerializedDagModel(Base):
                 .order_by(DagVersion.version_number.desc())
                 .limit(1)
             )
-            return select(cls).where(cls.id == latest_item_id)
+            return select(cls).where(cls.id == 
latest_item_id.scalar_subquery())
         return (
             select(cls)
             .join(DagVersion, cls.dag_version_id == DagVersion.id)
diff --git a/pyproject.toml b/pyproject.toml
index d43d97b5851..8f7bea29d61 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1034,6 +1034,7 @@ filterwarnings = [
     # Avoid building cartesian product which might impact performance
     "error:SELECT statement has a cartesian product between 
FROM:sqlalchemy.exc.SAWarning:airflow",
     'error:Coercing Subquery object into a select\(\) for use in 
IN\(\):sqlalchemy.exc.SAWarning:airflow',
+    'error:implicitly coercing SELECT object to scalar 
subquery:sqlalchemy.exc.SAWarning:airflow',
     'error:Class.*will not make use of SQL compilation caching',
     "ignore::DeprecationWarning:flask_appbuilder.filemanager",
     "ignore::DeprecationWarning:flask_appbuilder.widgets",

Reply via email to