From c8bebaf272b09b4b416084a8eb5694fa2ca80840 Mon Sep 17 00:00:00 2001
From: Dev-iL <6509619+Dev-iL@users.noreply.github.com>
Date: Thu, 29 Jan 2026 22:04:25 +0200
Subject: [PATCH 1/3] Force install SQLA2.1

---
 Dockerfile.ci                   | 1 +
 scripts/docker/entrypoint_ci.sh | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Dockerfile.ci b/Dockerfile.ci
index 2379df5129777..51196028a0c1b 100644
--- a/Dockerfile.ci
+++ b/Dockerfile.ci
@@ -1414,6 +1414,7 @@ function check_upgrade_sqlalchemy() {
     echo
     uv sync --all-packages --no-install-package apache-airflow-providers-fab --resolution highest \
         --no-python-downloads --no-managed-python
+    uv pip install "sqlalchemy>=2.1.0b1" --prerelease=allow
 }
 
 function check_downgrade_sqlalchemy() {
diff --git a/scripts/docker/entrypoint_ci.sh b/scripts/docker/entrypoint_ci.sh
index 18f2efbe67392..d5b275e66459f 100755
--- a/scripts/docker/entrypoint_ci.sh
+++ b/scripts/docker/entrypoint_ci.sh
@@ -339,6 +339,7 @@ function check_upgrade_sqlalchemy() {
     echo
     uv sync --all-packages --no-install-package apache-airflow-providers-fab --resolution highest \
         --no-python-downloads --no-managed-python
+    uv pip install "sqlalchemy>=2.1.0b1" --prerelease=allow
 }
 
 # Download minimum supported version of sqlalchemy to run tests with it

From 0091f7df0472d47a82813e272af284acc3a3059d Mon Sep 17 00:00:00 2001
From: Dev-iL <6509619+Dev-iL@users.noreply.github.com>
Date: Wed, 18 Feb 2026 09:04:45 +0200
Subject: [PATCH 2/3] Include the latest snowflake-sqlalchemy

---
 Dockerfile.ci                   | 2 +-
 scripts/docker/entrypoint_ci.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Dockerfile.ci b/Dockerfile.ci
index 51196028a0c1b..a6b9e46da5d6f 100644
--- a/Dockerfile.ci
+++ b/Dockerfile.ci
@@ -1414,7 +1414,7 @@ function check_upgrade_sqlalchemy() {
     echo
     uv sync --all-packages --no-install-package apache-airflow-providers-fab --resolution highest \
         --no-python-downloads --no-managed-python
-    uv pip install "sqlalchemy>=2.1.0b1" --prerelease=allow
+    uv pip install "sqlalchemy>=2.1.0b1" "snowflake-sqlalchemy @ git+https://github.com/snowflakedb/snowflake-sqlalchemy.git@main" --prerelease=allow
 }
 
 function check_downgrade_sqlalchemy() {
diff --git a/scripts/docker/entrypoint_ci.sh b/scripts/docker/entrypoint_ci.sh
index d5b275e66459f..283a3b9957bff 100755
--- a/scripts/docker/entrypoint_ci.sh
+++ b/scripts/docker/entrypoint_ci.sh
@@ -339,7 +339,7 @@ function check_upgrade_sqlalchemy() {
     echo
     uv sync --all-packages --no-install-package apache-airflow-providers-fab --resolution highest \
         --no-python-downloads --no-managed-python
-    uv pip install "sqlalchemy>=2.1.0b1" --prerelease=allow
+    uv pip install "sqlalchemy>=2.1.0b1" "snowflake-sqlalchemy @ git+https://github.com/snowflakedb/snowflake-sqlalchemy.git@main" --prerelease=allow
 }
 
 # Download minimum supported version of sqlalchemy to run tests with it

From 4d8684775aacd8dc42b7fb446264a821d29c687b Mon Sep 17 00:00:00 2001
From: Dev-iL <6509619+Dev-iL@users.noreply.github.com>
Date: Wed, 18 Feb 2026 10:51:44 +0200
Subject: [PATCH 3/3] Skip/ignore snowflake test failures related to SQLA2.1

- Ignore import error in `TestStringifiedDAGs`, `TestSQLCheckOperatorDbHook`, and `test_should_be_importable`.
- Skip all snowflake provider tests (since the foundational `SnowflakeHook` is not importable).
---
 .../tests/unit/always/test_example_dags.py       |  5 +++++
 .../unit/serialization/test_dag_serialization.py |  2 ++
 .../tests/unit/common/sql/operators/test_sql.py  | 16 ++++++++++++++++
 providers/snowflake/tests/conftest.py            |  6 ++++++
 4 files changed, 29 insertions(+)

diff --git a/airflow-core/tests/unit/always/test_example_dags.py b/airflow-core/tests/unit/always/test_example_dags.py
index bd9c5478bd76d..066c6d70f97de 100644
--- a/airflow-core/tests/unit/always/test_example_dags.py
+++ b/airflow-core/tests/unit/always/test_example_dags.py
@@ -221,6 +221,11 @@ def test_should_be_importable(example: str, patch_get_dagbag_import_timeout):
         pytest.skip(
             f"Skipping {example} because it requires an optional provider feature that is not installed."
         )
+    # snowflake-sqlalchemy does not yet support SQLAlchemy 2.1
+    if len(dagbag.import_errors) == 1 and "ORMSelectCompileState" in str(dagbag.import_errors):
+        pytest.skip(
+            f"Skipping {example} because snowflake-sqlalchemy is incompatible with installed SQLAlchemy."
+        )
     assert len(dagbag.import_errors) == 0, f"import_errors={str(dagbag.import_errors)}"
     assert len(dagbag.dag_ids) >= 1
 
diff --git a/airflow-core/tests/unit/serialization/test_dag_serialization.py b/airflow-core/tests/unit/serialization/test_dag_serialization.py
index b8156abd67eb9..a23a1285ebf0e 100644
--- a/airflow-core/tests/unit/serialization/test_dag_serialization.py
+++ b/airflow-core/tests/unit/serialization/test_dag_serialization.py
@@ -576,6 +576,8 @@ def test_serialization(self):
                 f"{ignore_module_import_error}" not in error
                 for ignore_module_import_error in IGNORE_MODULE_IMPORT_ERRORS
             )
+            # snowflake-sqlalchemy does not yet support SQLAlchemy 2.1
+            if "module 'sqlalchemy.orm.context' has no attribute 'ORMSelectCompileState'" not in error
         }
 
         # Let's not be exact about this, but if everything fails to parse we should fail this test too
diff --git a/providers/common/sql/tests/unit/common/sql/operators/test_sql.py b/providers/common/sql/tests/unit/common/sql/operators/test_sql.py
index 14380b717363c..c5aaba72548ef 100644
--- a/providers/common/sql/tests/unit/common/sql/operators/test_sql.py
+++ b/providers/common/sql/tests/unit/common/sql/operators/test_sql.py
@@ -72,6 +72,14 @@
 
 pytestmark = pytest.mark.db_test
 
+# snowflake-sqlalchemy does not yet support SQLAlchemy 2.1
+try:
+    from snowflake.sqlalchemy import URL  # noqa: F401
+
+    _snowflake_sqlalchemy_available = True
+except (ImportError, AttributeError):
+    _snowflake_sqlalchemy_available = False
+
 
 class MockHook:
     def get_records(self):
@@ -735,6 +743,10 @@ def test_not_allowed_conn_type(self):
                 self._operator._hook
 
     @skip_if_force_lowest_dependencies_marker
+    @pytest.mark.skipif(
+        not _snowflake_sqlalchemy_available,
+        reason="snowflake-sqlalchemy is incompatible with installed SQLAlchemy",
+    )
     def test_sql_operator_hook_params_snowflake(self):
         with mock.patch(
             "airflow.providers.common.sql.operators.sql.BaseHook.get_connection",
@@ -770,6 +782,10 @@ def test_sql_operator_hook_params_biguery(self):
             assert self._operator._hook.location == "us-east1"
 
     @skip_if_force_lowest_dependencies_marker
+    @pytest.mark.skipif(
+        not _snowflake_sqlalchemy_available,
+        reason="snowflake-sqlalchemy is incompatible with installed SQLAlchemy",
+    )
     def test_sql_operator_hook_params_templated(self):
         with mock.patch(
             "airflow.providers.common.sql.operators.sql.BaseHook.get_connection",
diff --git a/providers/snowflake/tests/conftest.py b/providers/snowflake/tests/conftest.py
index f56ccce0a3f69..a27af1d4514e5 100644
--- a/providers/snowflake/tests/conftest.py
+++ b/providers/snowflake/tests/conftest.py
@@ -17,3 +17,9 @@
 from __future__ import annotations
 
 pytest_plugins = "tests_common.pytest_plugin"
+
+# snowflake-sqlalchemy does not yet support SQLAlchemy 2.1
+try:
+    from snowflake.sqlalchemy import URL  # noqa: F401
+except AttributeError:
+    collect_ignore_glob = ["*"]
