Skip to content

Commit

Permalink
Propose fix for connection testing issues in Cloud. (#836)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Cassell <[email protected]>
  • Loading branch information
VersusFacit and benc-db authored Oct 24, 2024
1 parent 84fc024 commit da3a9f9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Fix places where we were not properly closing cursors, and other test warnings ([713](https://github.com/databricks/dbt-databricks/pull/713))
- Drop support for Python 3.8 ([713](https://github.com/databricks/dbt-databricks/pull/713))
- Upgrade databricks-sql-connector dependency to 3.5.0 ([833](https://github.com/databricks/dbt-databricks/pull/833))
- Fix behavior flag use in init of DatabricksAdapter ([836](https://github.com/databricks/dbt-databricks/pull/836/files))

## dbt-databricks 1.8.7 (October 10, 2024)

Expand Down
14 changes: 10 additions & 4 deletions dbt/adapters/databricks/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
from dbt_common.behavior_flags import BehaviorFlag
from dbt_common.utils import executor
from dbt_common.utils.dict import AttrDict
from dbt_common.exceptions import CompilationError
from dbt_common.exceptions import DbtConfigError
from dbt_common.exceptions import DbtInternalError
from dbt_common.contracts.config.base import BaseConfig
Expand Down Expand Up @@ -182,10 +183,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]:
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/adapter/columns/test_get_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "--connection"])

util.run_dbt(["run"])

@pytest.fixture(scope="class")
Expand Down

0 comments on commit da3a9f9

Please sign in to comment.