Skip to content

Commit

Permalink
make host/port configurable for Snowflake connections (#44079)
Browse files Browse the repository at this point in the history
  • Loading branch information
whummer authored Nov 16, 2024
1 parent 3917730 commit d8bff00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Extra (optional)
* ``private_key_content``: Specify the content of the private key file.
* ``session_parameters``: Specify `session level parameters <https://docs.snowflake.com/en/user-guide/python-connector-example.html#setting-session-parameters>`_.
* ``insecure_mode``: Turn off OCSP certificate checks. For details, see: `How To: Turn Off OCSP Checking in Snowflake Client Drivers - Snowflake Community <https://community.snowflake.com/s/article/How-to-turn-off-OCSP-checking-in-Snowflake-client-drivers>`_.
* ``host``: Target Snowflake hostname to connect to (e.g., for local testing with LocalStack).
* ``port``: Target Snowflake port to connect to (e.g., for local testing with LocalStack).

URI format example
^^^^^^^^^^^^^^^^^^
Expand Down
8 changes: 8 additions & 0 deletions providers/src/airflow/providers/snowflake/hooks/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ def _get_conn_params(self) -> dict[str, str | None]:
conn_config.pop("login", None)
conn_config.pop("password", None)

# configure custom target hostname and port, if specified
snowflake_host = extra_dict.get("host")
snowflake_port = extra_dict.get("port")
if snowflake_host:
conn_config["host"] = snowflake_host
if snowflake_port:
conn_config["port"] = snowflake_port

return conn_config

def get_uri(self) -> str:
Expand Down

0 comments on commit d8bff00

Please sign in to comment.