1717
1818if TYPE_CHECKING :
1919 from databricks .sql .client import Cursor
20- from databricks .sql .result_set import SeaResultSet
20+ from databricks .sql .backend . sea . result_set import SeaResultSet
2121
2222from databricks .sql .backend .databricks_client import DatabricksClient
2323from databricks .sql .backend .types import (
@@ -251,7 +251,7 @@ def close_session(self, session_id: SessionId) -> None:
251251 logger .debug ("SeaDatabricksClient.close_session(session_id=%s)" , session_id )
252252
253253 if session_id .backend_type != BackendType .SEA :
254- raise ProgrammingError ("Not a valid SEA session ID" )
254+ raise ValueError ("Not a valid SEA session ID" )
255255 sea_session_id = session_id .to_sea_session_id ()
256256
257257 request_data = DeleteSessionRequest (
@@ -290,7 +290,7 @@ def get_allowed_session_configurations() -> List[str]:
290290
291291 def _extract_description_from_manifest (
292292 self , manifest : ResultManifest
293- ) -> Optional [ List ]:
293+ ) -> List [ Tuple ]:
294294 """
295295 Extract column description from a manifest object, in the format defined by
296296 the spec: https://peps.python.org/pep-0249/#description
@@ -299,15 +299,12 @@ def _extract_description_from_manifest(
299299 manifest: The ResultManifest object containing schema information
300300
301301 Returns:
302- Optional[ List]: A list of column tuples or None if no columns are found
302+ List[Tuple ]: A list of column tuples
303303 """
304304
305305 schema_data = manifest .schema
306306 columns_data = schema_data .get ("columns" , [])
307307
308- if not columns_data :
309- return None
310-
311308 columns = []
312309 for col_data in columns_data :
313310 # Format: (name, type_code, display_size, internal_size, precision, scale, null_ok)
@@ -323,7 +320,7 @@ def _extract_description_from_manifest(
323320 )
324321 )
325322
326- return columns if columns else None
323+ return columns
327324
328325 def _results_message_to_execute_response (
329326 self , response : GetStatementResponse
@@ -429,7 +426,7 @@ def execute_command(
429426 """
430427
431428 if session_id .backend_type != BackendType .SEA :
432- raise ProgrammingError ("Not a valid SEA session ID" )
429+ raise ValueError ("Not a valid SEA session ID" )
433430
434431 sea_session_id = session_id .to_sea_session_id ()
435432
@@ -508,9 +505,11 @@ def cancel_command(self, command_id: CommandId) -> None:
508505 """
509506
510507 if command_id .backend_type != BackendType .SEA :
511- raise ProgrammingError ("Not a valid SEA command ID" )
508+ raise ValueError ("Not a valid SEA command ID" )
512509
513510 sea_statement_id = command_id .to_sea_statement_id ()
511+ if sea_statement_id is None :
512+ raise ValueError ("Not a valid SEA command ID" )
514513
515514 request = CancelStatementRequest (statement_id = sea_statement_id )
516515 self .http_client ._make_request (
@@ -531,9 +530,11 @@ def close_command(self, command_id: CommandId) -> None:
531530 """
532531
533532 if command_id .backend_type != BackendType .SEA :
534- raise ProgrammingError ("Not a valid SEA command ID" )
533+ raise ValueError ("Not a valid SEA command ID" )
535534
536535 sea_statement_id = command_id .to_sea_statement_id ()
536+ if sea_statement_id is None :
537+ raise ValueError ("Not a valid SEA command ID" )
537538
538539 request = CloseStatementRequest (statement_id = sea_statement_id )
539540 self .http_client ._make_request (
@@ -560,6 +561,8 @@ def get_query_state(self, command_id: CommandId) -> CommandState:
560561 raise ValueError ("Not a valid SEA command ID" )
561562
562563 sea_statement_id = command_id .to_sea_statement_id ()
564+ if sea_statement_id is None :
565+ raise ValueError ("Not a valid SEA command ID" )
563566
564567 request = GetStatementRequest (statement_id = sea_statement_id )
565568 response_data = self .http_client ._make_request (
@@ -592,9 +595,11 @@ def get_execution_result(
592595 """
593596
594597 if command_id .backend_type != BackendType .SEA :
595- raise ProgrammingError ("Not a valid SEA command ID" )
598+ raise ValueError ("Not a valid SEA command ID" )
596599
597600 sea_statement_id = command_id .to_sea_statement_id ()
601+ if sea_statement_id is None :
602+ raise ValueError ("Not a valid SEA command ID" )
598603
599604 # Create the request model
600605 request = GetStatementRequest (statement_id = sea_statement_id )
@@ -608,18 +613,18 @@ def get_execution_result(
608613 response = GetStatementResponse .from_dict (response_data )
609614
610615 # Create and return a SeaResultSet
611- from databricks .sql .result_set import SeaResultSet
616+ from databricks .sql .backend . sea . result_set import SeaResultSet
612617
613618 execute_response = self ._results_message_to_execute_response (response )
614619
615620 return SeaResultSet (
616621 connection = cursor .connection ,
617622 execute_response = execute_response ,
618623 sea_client = self ,
619- buffer_size_bytes = cursor .buffer_size_bytes ,
620- arraysize = cursor .arraysize ,
621624 result_data = response .result ,
622625 manifest = response .manifest ,
626+ buffer_size_bytes = cursor .buffer_size_bytes ,
627+ arraysize = cursor .arraysize ,
623628 )
624629
625630 # == Metadata Operations ==
0 commit comments