From 4442f2ab6767760fe3b751f6dc7d71004f7f5fac Mon Sep 17 00:00:00 2001 From: Javier Calvo Date: Tue, 8 Mar 2022 18:42:42 +0100 Subject: [PATCH 1/3] added macro for wh selection and adapted adapter's _use_warehouse method accordingly --- dbt/adapters/snowflake/impl.py | 7 +++++++ dbt/include/snowflake/macros/etc.sql | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 dbt/include/snowflake/macros/etc.sql diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index e609ba5f5..c24090b5e 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -82,6 +82,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..131316205 --- /dev/null +++ b/dbt/include/snowflake/macros/etc.sql @@ -0,0 +1,3 @@ +{% macro snowflake_warehouse(warehouse) -%} + {{ return(warehouse) }} +{%- endmacro %} \ No newline at end of file From aa140c2e3976a548f2580ce783e70e5f75312c22 Mon Sep 17 00:00:00 2001 From: Javier Calvo Date: Tue, 8 Mar 2022 18:48:00 +0100 Subject: [PATCH 2/3] added macro name variable --- dbt/adapters/snowflake/impl.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index c24090b5e..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 From 86e1cc7dbf36266d62656f3d07fe8d820347bed5 Mon Sep 17 00:00:00 2001 From: Javier Calvo Date: Mon, 21 Mar 2022 15:52:09 +0100 Subject: [PATCH 3/3] added missign newline at the end --- dbt/include/snowflake/macros/etc.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt/include/snowflake/macros/etc.sql b/dbt/include/snowflake/macros/etc.sql index 131316205..f77925599 100644 --- a/dbt/include/snowflake/macros/etc.sql +++ b/dbt/include/snowflake/macros/etc.sql @@ -1,3 +1,3 @@ {% macro snowflake_warehouse(warehouse) -%} {{ return(warehouse) }} -{%- endmacro %} \ No newline at end of file +{%- endmacro %}