From c4f89cc45dabdc93c0fd63ca561017b43fd45a94 Mon Sep 17 00:00:00 2001 From: McKnight-42 Date: Tue, 4 Jun 2024 15:00:02 -0500 Subject: [PATCH] init attempt of adding logger.info for model_hooks --- dbt/adapters/snowflake/impl.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index e3bc3ae0b..74573867e 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -7,6 +7,7 @@ from dbt.adapters.base.meta import available from dbt.adapters.capability import CapabilityDict, CapabilitySupport, Support, Capability from dbt.adapters.sql import SQLAdapter +from dbt.adapters.events.logging import AdapterLogger from dbt.adapters.sql.impl import ( LIST_SCHEMAS_MACRO_NAME, LIST_RELATIONS_MACRO_NAME, @@ -19,6 +20,8 @@ from dbt_common.exceptions import CompilationError, DbtDatabaseError, DbtRuntimeError from dbt_common.utils import filter_null_values +logger = AdapterLogger("Snowflake") + @dataclass class SnowflakeConfig(AdapterConfig): @@ -99,15 +102,20 @@ 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("snowflake_warehouse", default_warehouse) + logger.info(f"Running pre_model_hook with config: {config}") + logger.info(f"Default warehouse: {default_warehouse}, Selected warehouse: {warehouse}") if warehouse == default_warehouse or warehouse is None: return None previous = self._get_warehouse() self._use_warehouse(warehouse) + logger.info(f"Changed warehouse from {previous} to {warehouse}") return previous def post_model_hook(self, config: Mapping[str, Any], context: Optional[str]) -> None: + logger.info(f"Running post_model_hook with config: {config} and context: {context}") if context is not None: self._use_warehouse(context) + logger.info(f"Restored warehouse to {context}") def list_schemas(self, database: str) -> List[str]: try: