Skip to content

Commit

Permalink
init attempt of adding logger.info for model_hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
McKnight-42 committed Jun 4, 2024
1 parent 4ff6bdb commit c4f89cc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dbt/adapters/snowflake/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c4f89cc

Please sign in to comment.