Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename "warehouse" config key to "snowflake_warehouse" (#1899) #1901

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/snowflake/dbt/adapters/snowflake/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SnowflakeAdapter(SQLAdapter):

AdapterSpecificConfigs = frozenset(
{"transient", "cluster_by", "automatic_clustering", "secure",
"copy_grants", "warehouse"}
"copy_grants", "snowflake_warehouse"}
)

@classmethod
Expand Down Expand Up @@ -62,7 +62,7 @@ def _use_warehouse(self, warehouse: str):

def pre_model_hook(self, config: Mapping[str, Any]) -> Optional[str]:
default_warehouse = self.config.credentials.warehouse
warehouse = config.get('warehouse', default_warehouse)
warehouse = config.get('snowflake_warehouse', default_warehouse)
if warehouse == default_warehouse or warehouse is None:
return None
previous = self._get_warehouse()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{{ config(warehouse='DBT_TEST_DOES_NOT_EXIST') }}
{{ config(snowflake_warehouse='DBT_TEST_DOES_NOT_EXIST') }}
select current_warehouse() as warehouse
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{{ config(warehouse='DBT_TEST_ALT', materialized='table') }}
{{ config(snowflake_warehouse='DBT_TEST_ALT', materialized='table') }}
select current_warehouse() as warehouse
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ config(materialized='table') }}
select 'DBT_TEST_ALT' as warehouse
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ config(materialized='table') }}
select current_warehouse() as warehouse
35 changes: 34 additions & 1 deletion test/integration/050_warehouse_test/test_warehouses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os


class TestDebug(DBTIntegrationTest):
class TestModelWarehouse(DBTIntegrationTest):
@property
def schema(self):
return 'dbt_warehouse_050'
Expand All @@ -26,3 +26,36 @@ def test_snowflake_override_ok(self):
@use_profile('snowflake')
def test_snowflake_override_noexist(self):
self.run_dbt(['run', '--models', 'invalid_warehouse'], expect_pass=False)


class TestConfigWarehouse(DBTIntegrationTest):
@property
def schema(self):
return 'dbt_warehouse_050'

@property
def project_config(self):
return {
'source-paths': ['project-config-models'],
'models': {
'test': {
'snowflake_warehouse': 'DBT_TEST_ALT',
},
},
}

@staticmethod
def dir(value):
return os.path.normpath(value)

@property
def models(self):
return self.dir('models')

@use_profile('snowflake')
def test_snowflake_override_ok(self):
self.run_dbt([
'run',
'--models', 'override_warehouse', 'expected_warehouse',
])
self.assertManyRelationsEqual([['OVERRIDE_WAREHOUSE'], ['EXPECTED_WAREHOUSE']])
2 changes: 1 addition & 1 deletion test/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def run_sql_common(self, sql, fetch, conn):
else:
return
except BaseException as e:
if conn.handle and conn.handle.closed != 0:
if conn.handle and not conn.handle.is_closed():
conn.handle.rollback()
print(sql)
print(e)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_snowflake_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _strip_transactions(self):

def test_pre_post_hooks_warehouse(self):
with self.current_warehouse('warehouse'):
config = {'warehouse': 'other_warehouse'}
config = {'snowflake_warehouse': 'other_warehouse'}
result = self.adapter.pre_model_hook(config)
self.assertIsNotNone(result)
calls = [
Expand Down