kaxil opened a new pull request, #75334: URL: https://github.com/apache/airflow/pull/75334
On `snowflake-connector-python` 5.0, each connection `SnowflakeHook` opens logs two warnings: ``` UserWarning: Unknown parameter 'region' FutureWarning: enable_server_session_keep_alive_auto_detection was not set and defaults to True. In a future version, the default will change to None. ... ``` The `region` one is more than noise. Connector 5 dropped the argument and builds the host from `account` alone, so a connection with the `region` extra set now dials `<account>.snowflakecomputing.com` instead of `<account>.<region>.snowflakecomputing.com` (checked against the 5.0.0 wheel by logging the host it connects to). The hook passes `region` on every connection, as `""` when none is configured, hence the warning even without a region. The second argument controls whether `close()` checks for async queries still running on the connection before logging out. `True` keeps the session so they finish; `None`/`False` logs out and the server may terminate them. Connectors 3.17 and 4.8 behave as `True` (their `close()` deletes the session only once all async queries are done), so when 5.x flips the default, logout behaviour changes for Airflow users with nothing changed on their side. What the hook does now, on connector 5 only: - `region` is no longer sent. If one is set, the hook passes the host that `construct_hostname()` in earlier connectors built from it: `us-west-2` adds nothing, `cn-` regions use `.snowflakecomputing.cn`, and the region replaces any region already in `account`. An explicit `host` extra still wins. Account and region go through `_validate_account_component` first, same as `account_identifier`. - `enable_server_session_keep_alive_auto_detection=True` is passed unless the connection sets the new extra of that name. The SQLAlchemy engine gets it via `connect_args`; a value the caller already put in `engine_kwargs["connect_args"]` is left alone. Before connector 5, connect kwargs are the same as on main, minus the new extra (those connectors don't accept it). The version comes from `snowflake.connector.version.VERSION`; the provider floor stays at 3.17.0. ## Design rationale `_get_conn_params()` keeps `region`. The SQL API hook (`account_identifier`) and the Cortex REST helpers in `utils/_rest_auth.py` build URLs from it. So the reshaping lives in a new `_get_connector_params()`, used only by `get_conn()` and `get_snowpark_session()`, the two callers that hand the dict to the connector. SQLAlchemy needs no region change: snowflake-sqlalchemy already puts the region into the URL host. I first tried folding the region into `account` and letting connector 5 build the host. It gets the right host for most regions, but always with `.com`: on 5.0.0, `account="x.cn-north-1.aws"` dials `x.cn-north-1.aws.snowflakecomputing.com`. Passing `host` with a bare account reaches the same host the older connectors did, China included. On the new extra: pinning `True` would be enough to silence the warning. The extra is there for anyone who runs `execute_async` on a `get_conn()` connection and wants close to always log out. It's read straight from the extra like `ocsp_fail_open`, not through `_get_field`, which turns an explicit `false` into `None`. The form checkbox defaults to checked (like `use_tls` in the HashiCorp provider), since an unchecked box saves `false`. Tests patch the version check rather than depend on the installed connector, because `uv.lock` resolves 4.8.0 below Python 3.15 and 5.0.0rc5 on 3.15. Run against main's hook, the connector-5 tests fail with `region` in the connect kwargs and no keep-alive argument. -- 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]
