@@ -259,7 +259,7 @@ def close_session(self, session_id: SessionId) -> None:
259259 logger .debug ("SeaDatabricksClient.close_session(session_id=%s)" , session_id )
260260
261261 if session_id .backend_type != BackendType .SEA :
262- raise ValueError ("Not a valid SEA session ID" )
262+ raise ProgrammingError ("Not a valid SEA session ID" )
263263 sea_session_id = session_id .to_sea_session_id ()
264264
265265 request_data = DeleteSessionRequest (
@@ -298,7 +298,7 @@ def get_allowed_session_configurations() -> List[str]:
298298
299299 def _extract_description_from_manifest (
300300 self , manifest : ResultManifest
301- ) -> List [ Tuple ]:
301+ ) -> Optional [ List ]:
302302 """
303303 Extract column description from a manifest object, in the format defined by
304304 the spec: https://peps.python.org/pep-0249/#description
@@ -307,12 +307,15 @@ def _extract_description_from_manifest(
307307 manifest: The ResultManifest object containing schema information
308308
309309 Returns:
310- List[Tuple ]: A list of column tuples
310+ Optional[List ]: A list of column tuples or None if no columns are found
311311 """
312312
313313 schema_data = manifest .schema
314314 columns_data = schema_data .get ("columns" , [])
315315
316+ if not columns_data :
317+ return None
318+
316319 columns = []
317320 for col_data in columns_data :
318321 # Format: (name, type_code, display_size, internal_size, precision, scale, null_ok)
@@ -328,7 +331,7 @@ def _extract_description_from_manifest(
328331 )
329332 )
330333
331- return columns
334+ return columns if columns else None
332335
333336 def _results_message_to_execute_response (
334337 self , response : Union [ExecuteStatementResponse , GetStatementResponse ]
@@ -459,7 +462,7 @@ def execute_command(
459462 """
460463
461464 if session_id .backend_type != BackendType .SEA :
462- raise ValueError ("Not a valid SEA session ID" )
465+ raise ProgrammingError ("Not a valid SEA session ID" )
463466
464467 sea_session_id = session_id .to_sea_session_id ()
465468
@@ -547,11 +550,9 @@ def cancel_command(self, command_id: CommandId) -> None:
547550 """
548551
549552 if command_id .backend_type != BackendType .SEA :
550- raise ValueError ("Not a valid SEA command ID" )
553+ raise ProgrammingError ("Not a valid SEA command ID" )
551554
552555 sea_statement_id = command_id .to_sea_statement_id ()
553- if sea_statement_id is None :
554- raise ValueError ("Not a valid SEA command ID" )
555556
556557 request = CancelStatementRequest (statement_id = sea_statement_id )
557558 self .http_client ._make_request (
@@ -572,11 +573,9 @@ def close_command(self, command_id: CommandId) -> None:
572573 """
573574
574575 if command_id .backend_type != BackendType .SEA :
575- raise ValueError ("Not a valid SEA command ID" )
576+ raise ProgrammingError ("Not a valid SEA command ID" )
576577
577578 sea_statement_id = command_id .to_sea_statement_id ()
578- if sea_statement_id is None :
579- raise ValueError ("Not a valid SEA command ID" )
580579
581580 request = CloseStatementRequest (statement_id = sea_statement_id )
582581 self .http_client ._make_request (
@@ -594,8 +593,6 @@ def _poll_query(self, command_id: CommandId) -> GetStatementResponse:
594593 raise ValueError ("Not a valid SEA command ID" )
595594
596595 sea_statement_id = command_id .to_sea_statement_id ()
597- if sea_statement_id is None :
598- raise ValueError ("Not a valid SEA command ID" )
599596
600597 request = GetStatementRequest (statement_id = sea_statement_id )
601598 response_data = self .http_client ._make_request (
0 commit comments