Skip to content

Commit 35bffec

Browse files
authored
Lazy init api client for connection manager to fix 940 (#941)
1 parent 2ccd729 commit 35bffec

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## dbt-databricks 1.9.6 (TBD)
22

3+
### Fixes
4+
5+
- Fix for parse raising error for not having credentials ([941](https://github.com/databricks/dbt-databricks/pull/941))
6+
37
### Under the Hood
48

59
- Refactoring of some connection internals ([929](https://github.com/databricks/dbt-databricks/pull/929))

dbt/adapters/databricks/connections.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,19 @@ class DatabricksConnectionManager(SparkConnectionManager):
202202

203203
def __init__(self, profile: AdapterRequiredConfig, mp_context: SpawnContext):
204204
super().__init__(profile, mp_context)
205-
creds = cast(DatabricksCredentials, self.profile.credentials)
206-
self.api_client = DatabricksApiClient.create(creds, 15 * 60)
205+
self._api_client: Optional[DatabricksApiClient] = None
207206
self.threads_compute_connections: dict[
208207
Hashable, dict[Hashable, DatabricksDBTConnection]
209208
] = {}
210209

210+
@property
211+
def api_client(self) -> DatabricksApiClient:
212+
if self._api_client is None:
213+
self._api_client = DatabricksApiClient.create(
214+
cast(DatabricksCredentials, self.profile.credentials), 15 * 60
215+
)
216+
return self._api_client
217+
211218
def cancel_open(self) -> list[str]:
212219
cancelled = super().cancel_open()
213220
logger.info("Cancelling open python jobs")

0 commit comments

Comments
 (0)