kaxil commented on code in PR #75334:
URL: https://github.com/apache/airflow/pull/75334#discussion_r4339856235


##########
providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake.py:
##########
@@ -849,6 +906,12 @@ def get_sqlalchemy_engine(self, engine_kwargs=None):
         if "ocsp_fail_open" in conn_params:
             engine_kwargs.setdefault("connect_args", {})
             engine_kwargs["connect_args"]["ocsp_fail_open"] = 
conn_params["ocsp_fail_open"]
+        if _is_connector_5_or_later():

Review Comment:
   Checked this one. The engine path never hands `region` to the connector: 
snowflake-sqlalchemy turns the URL host `account.region` into an explicit 
`host` (`account.region.snowflakecomputing.com`) plus a bare `account`. Against 
5.0.0 + snowflake-sqlalchemy 2.0.0 it dials the same host `get_conn` now uses. 
China regions land on `.com` through this path, but they do on 4.8 + 
snowflake-sqlalchemy 1.11.1 too, so that's snowflake-sqlalchemy's behaviour and 
not something this PR changes.



##########
providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake.py:
##########
@@ -823,11 +853,38 @@ def _conn_params_to_sqlalchemy_uri(self, conn_params: 
dict) -> str:
             }
         )
 
+    def _get_connector_params(self) -> dict[str, Any]:
+        """
+        Return ``_get_conn_params()`` in the form the installed 
``snowflake-connector-python`` accepts.
+
+        Connector 5 ignores ``region`` and builds the host from ``account`` 
alone, so the hook
+        passes the host earlier connectors built from the region instead. It 
also warns on every
+        connection unless ``enable_server_session_keep_alive_auto_detection`` 
is set, which earlier
+        connectors don't accept.
+        """
+        conn_params: dict[str, Any] = self._get_conn_params()
+
+        if not _is_connector_5_or_later():
+            conn_params.pop(LOGOUT_AUTO_DETECTION_PARAM, None)
+            return conn_params
+
+        region = conn_params.pop("region")

Review Comment:
   Good call, done in 89803423fb8.



-- 
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]

Reply via email to