Skip to content

Commit c78bace

Browse files
committed
simplify close_session (remove secondary _close_session invocation)
1 parent b97ac03 commit c78bace

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/databricks/sql/backend/sea/backend.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def open_session(
273273

274274
return SessionId.from_sea_session_id(session_id)
275275

276-
def _close_session(self, session_id: SessionId) -> None:
276+
def close_session(self, session_id: SessionId) -> None:
277277
"""
278278
Closes an existing session with the Databricks SQL service.
279279
@@ -285,9 +285,9 @@ def _close_session(self, session_id: SessionId) -> None:
285285
OperationalError: If there's an error closing the session
286286
"""
287287

288-
if session_id.backend_type != BackendType.SEA:
289-
raise ValueError("Not a valid SEA session ID")
290288
sea_session_id = session_id.to_sea_session_id()
289+
if sea_session_id is None:
290+
raise ValueError("Not a valid SEA session ID")
291291

292292
request_data = DeleteSessionRequest(
293293
warehouse_id=self.warehouse_id,
@@ -300,21 +300,7 @@ def _close_session(self, session_id: SessionId) -> None:
300300
data=request_data.to_dict(),
301301
)
302302

303-
def close_session(self, session_id: SessionId) -> None:
304-
"""
305-
Closes the session and the underlying HTTP client.
306-
307-
Args:
308-
session_id: The session identifier returned by open_session()
309-
310-
Raises:
311-
ValueError: If the session ID is invalid
312-
OperationalError: If there's an error closing the session
313-
"""
314-
315-
logger.debug("SeaDatabricksClient.close_session(session_id=%s)", session_id)
316-
317-
self._close_session(session_id)
303+
# close the HTTP client
318304
self._http_client.close()
319305

320306
def _extract_description_from_manifest(

0 commit comments

Comments
 (0)