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

Macro for warehouse selection #114

Closed
Closed
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
10 changes: 10 additions & 0 deletions dbt/adapters/snowflake/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]:
Expand Down
3 changes: 3 additions & 0 deletions dbt/include/snowflake/macros/etc.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro snowflake_warehouse(warehouse) -%}
{{ return(warehouse) }}
{%- endmacro %}