diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index e609ba5f5..3058c2856 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -19,6 +19,9 @@ from dbt.utils import filter_null_values +SNOWFLAKE_WAREHOUSE_MACRO_NAME = 'snowflake_warehouse' + + @dataclass class SnowflakeConfig(AdapterConfig): transient: Optional[bool] = None @@ -82,6 +85,13 @@ def _get_warehouse(self) -> str: def _use_warehouse(self, warehouse: str): """Use the given warehouse. Quotes are never applied.""" + kwargs = { + 'warehouse': warehouse + } + warehouse = self.execute_macro( + SNOWFLAKE_WAREHOUSE_MACRO_NAME, + kwargs=kwargs + ) self.execute('use warehouse {}'.format(warehouse)) def pre_model_hook(self, config: Mapping[str, Any]) -> Optional[str]: diff --git a/dbt/include/snowflake/macros/etc.sql b/dbt/include/snowflake/macros/etc.sql new file mode 100644 index 000000000..f77925599 --- /dev/null +++ b/dbt/include/snowflake/macros/etc.sql @@ -0,0 +1,3 @@ +{% macro snowflake_warehouse(warehouse) -%} + {{ return(warehouse) }} +{%- endmacro %}