Skip to content

Commit 98d1809

Browse files
Feat: pass session parameters for Snowflake (#2912)
1 parent d2c4025 commit 98d1809

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

docs/integrations/engines/snowflake.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pip install "sqlmesh[snowflake]"
2424
| `private_key` | The optional private key to use for authentication. Key can be Base64-encoded DER format (representing the key bytes), a plain-text PEM format, or bytes (Python config only). | string | N |
2525
| `private_key_path` | The optional path to the private key to use for authentication. This would be used instead of `private_key`. | string | N |
2626
| `private_key_passphrase` | The optional passphrase to use to decrypt `private_key` (if in PEM format) or `private_key_path`. Keys can be created without encryption so only provide this if needed. | string | N |
27+
| `session_parameters` | The optional session parameters to set for the connection. | dict | N |
2728

2829

2930
#### Lowercase object names

sqlmesh/core/config/connection.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class SnowflakeConnectionConfig(ConnectionConfig):
333333
private_key_passphrase: The optional passphrase to use to decrypt `private_key` or `private_key_path`. Keys can be created without encryption so only provide this if needed.
334334
register_comments: Whether or not to register model comments with the SQL engine.
335335
pre_ping: Whether or not to pre-ping the connection before starting a new transaction to ensure it is still alive.
336+
session_parameters: The optional session parameters to set for the connection.
336337
"""
337338

338339
account: str
@@ -353,6 +354,8 @@ class SnowflakeConnectionConfig(ConnectionConfig):
353354
register_comments: bool = True
354355
pre_ping: bool = False
355356

357+
session_parameters: t.Optional[dict] = None
358+
356359
type_: Literal["snowflake"] = Field(alias="type", default="snowflake")
357360

358361
_concurrent_tasks_validator = concurrent_tasks_validator
@@ -471,6 +474,7 @@ def _connection_kwargs_keys(self) -> t.Set[str]:
471474
"authenticator",
472475
"token",
473476
"private_key",
477+
"session_parameters",
474478
}
475479

476480
@property

tests/core/test_connection_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ def test_snowflake(make_config, snowflake_key_passphrase_bytes, snowflake_oauth_
183183
authenticator="oauth",
184184
)
185185

186+
# Can pass in session parameters
187+
config = make_config(
188+
type="snowflake",
189+
account="test",
190+
user="test",
191+
password="test",
192+
authenticator="externalbrowser",
193+
session_parameters={"query_tag": "test", "timezone": "UTC"},
194+
)
195+
assert isinstance(config, SnowflakeConnectionConfig)
196+
186197

187198
@pytest.mark.parametrize(
188199
"key_path_fixture, key_pem_fixture, key_b64_fixture, key_bytes_fixture, key_passphrase",

0 commit comments

Comments
 (0)