Skip to content

Commit

Permalink
Merge pull request #970 from borisuvarov/client_session_keep_alive_sn…
Browse files Browse the repository at this point in the history
…owflake

Add client_session_keep_alive parameter for Snowflake connection
  • Loading branch information
beckjake authored Sep 28, 2018
2 parents 6454a81 + 4da156f commit 95f3064
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dbt/adapters/snowflake/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def open_connection(cls, connection):
schema=credentials.schema,
warehouse=credentials.warehouse,
role=credentials.get('role', None),
autocommit=False
autocommit=False,
client_session_keep_alive=credentials.get(
'client_session_keep_alive', False)
)

connection.handle = handle
Expand Down
3 changes: 3 additions & 0 deletions dbt/contracts/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
'role': {
'type': 'string',
},
'client_session_keep_alive': {
'type': 'boolean',
}
},
'required': ['account', 'user', 'password', 'database', 'schema'],
}
Expand Down
23 changes: 23 additions & 0 deletions test/unit/test_snowflake_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,26 @@ def test_quoting_on_rename(self):
self.mock_execute.assert_has_calls([
mock.call('alter table "test_schema".table_a rename to table_b', None)
])

def test_client_session_keep_alive_false_by_default(self):
self.snowflake.assert_has_calls([
mock.call(
account='test_account', autocommit=False,
client_session_keep_alive=False, database='test_databse',
password='test_password', role=None, schema='public',
user='test_user', warehouse='test_warehouse')
])

def test_client_session_keep_alive_true(self):
self.config.credentials = self.config.credentials.incorporate(
client_session_keep_alive=True)
self.adapter = SnowflakeAdapter(self.config)
self.adapter.get_connection(name='new_connection_with_new_config')

self.snowflake.assert_has_calls([
mock.call(
account='test_account', autocommit=False,
client_session_keep_alive=True, database='test_databse',
password='test_password', role=None, schema='public',
user='test_user', warehouse='test_warehouse')
])

0 comments on commit 95f3064

Please sign in to comment.