Skip to content

Commit c6aae9e

Browse files
authored
Add s3_stage_vpce_dns_name session param (#1162)
Co-authored-by: Craig Squire <[email protected]>
1 parent b1bfad5 commit c6aae9e

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Add 's3_stage_vpce_dns_name' session parameter
3+
time: 2025-06-18T08:46:07.352953-05:00
4+
custom:
5+
Author: csquire
6+
Issue: "1161"

dbt-snowflake/src/dbt/adapters/snowflake/connections.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class SnowflakeCredentials(Credentials):
113113
insecure_mode: Optional[bool] = False
114114
# this needs to default to `None` so that we can tell if the user set it; see `__post_init__()`
115115
reuse_connections: Optional[bool] = None
116+
s3_stage_vpce_dns_name: Optional[str] = None
116117

117118
def __post_init__(self):
118119
if self.authenticator != "oauth" and (self.oauth_client_secret or self.oauth_client_id):
@@ -180,6 +181,7 @@ def _connection_keys(self):
180181
"retry_all",
181182
"insecure_mode",
182183
"reuse_connections",
184+
"s3_stage_vpce_dns_name",
183185
)
184186

185187
def auth_args(self):
@@ -370,6 +372,9 @@ def connect():
370372

371373
if creds.query_tag:
372374
session_parameters.update({"QUERY_TAG": creds.query_tag})
375+
376+
if creds.s3_stage_vpce_dns_name:
377+
session_parameters.update({"S3_STAGE_VPCE_DNS_NAME": creds.s3_stage_vpce_dns_name})
373378
handle = None
374379

375380
# In replay mode, we won't connect to a real database at all, while
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import pytest
2+
from dbt.tests.util import run_dbt
3+
4+
5+
models__test_model_sql = """
6+
{{ config(materialized = 'table') }}
7+
select 1 as id
8+
"""
9+
10+
11+
class TestS3StageVpceDnsName:
12+
"""
13+
Test that the s3_stage_vpce_dns_name session parameter is properly set
14+
when specified in the profile configuration.
15+
"""
16+
17+
@pytest.fixture(scope="class")
18+
def models(self):
19+
return {
20+
"test_model.sql": models__test_model_sql,
21+
}
22+
23+
@pytest.fixture(scope="class")
24+
def profiles_config_update(self, prefix, dbt_profile_target):
25+
outputs = {"default": dbt_profile_target}
26+
outputs["default"][
27+
"s3_stage_vpce_dns_name"
28+
] = f"vpce-{prefix}-xxxxxxxx.s3.us-east-1.vpce.amazonaws.com"
29+
30+
def test_s3_stage_vpce_dns_name_set(self, project, prefix):
31+
"""Test that the s3_stage_vpce_dns_name session parameter is properly set."""
32+
# Run dbt to create the model
33+
run_dbt(["run"])
34+
35+
# Check that the session parameter was set correctly
36+
result = project.run_sql(
37+
"show parameters like 'S3_STAGE_VPCE_DNS_NAME' in session", fetch="one"
38+
)
39+
assert result is not None
40+
expected_value = f"vpce-{prefix}-xxxxxxxx.s3.us-east-1.vpce.amazonaws.com"
41+
assert result[1] == expected_value, f"Expected {expected_value}, got {result[1]}"

0 commit comments

Comments
 (0)