From 8054bcb9b0a967953e65ccc7e257552fe727eef4 Mon Sep 17 00:00:00 2001 From: VersusFacit <67295367+VersusFacit@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:14:48 -0700 Subject: [PATCH] Propose fix for connection testing issues in Cloud. --- dbt/adapters/databricks/impl.py | 13 +++++++++---- .../functional/adapter/columns/test_get_columns.py | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dbt/adapters/databricks/impl.py b/dbt/adapters/databricks/impl.py index b275aa4f..b51ec971 100644 --- a/dbt/adapters/databricks/impl.py +++ b/dbt/adapters/databricks/impl.py @@ -182,10 +182,15 @@ class DatabricksAdapter(SparkAdapter): def __init__(self, config: Any, mp_context: SpawnContext) -> None: super().__init__(config, mp_context) - if self.behavior.use_info_schema_for_columns.no_warn: # type: ignore[attr-defined] - self.get_column_behavior = GetColumnsByInformationSchema() - else: - self.get_column_behavior = GetColumnsByDescribe() + + # dbt doesn't propogate flags for certain workflows like dbt debug so this requires + # an additional guard + self.get_column_behavior = GetColumnsByDescribe() + try: + if self.behavior.use_info_schema_for_columns.no_warn: # type: ignore[attr-defined] + self.get_column_behavior = GetColumnsByInformationSchema() + except CompilationError: + pass @property def _behavior_flags(self) -> List[BehaviorFlag]: diff --git a/tests/functional/adapter/columns/test_get_columns.py b/tests/functional/adapter/columns/test_get_columns.py index cf0a9e24..6983f37d 100644 --- a/tests/functional/adapter/columns/test_get_columns.py +++ b/tests/functional/adapter/columns/test_get_columns.py @@ -13,6 +13,9 @@ def models(self): @pytest.fixture(scope="class", autouse=True) def setup(self, project): + # debug uses different rules for managing project flags than run + util.run_dbt(["debug"]) + util.run_dbt(["run"]) @pytest.fixture(scope="class")