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 (
2727 BackendType ,
2828 ExecuteResponse ,
2929)
30- from databricks .sql .exc import DatabaseError , ProgrammingError , ServerOperationError
30+ from databricks .sql .exc import DatabaseError , ServerOperationError
3131from databricks .sql .backend .sea .utils .http_client import SeaHttpClient
3232from databricks .sql .types import SSLOptions
3333
@@ -150,7 +150,7 @@ def _extract_warehouse_id(self, http_path: str) -> str:
150150 The extracted warehouse ID
151151
152152 Raises:
153- ProgrammingError : If the warehouse ID cannot be extracted from the path
153+ ValueError : If the warehouse ID cannot be extracted from the path
154154 """
155155
156156 warehouse_pattern = re .compile (r".*/warehouses/(.+)" )
@@ -174,7 +174,7 @@ def _extract_warehouse_id(self, http_path: str) -> str:
174174 f"Note: SEA only works for warehouses."
175175 )
176176 logger .error (error_message )
177- raise ProgrammingError (error_message )
177+ raise ValueError (error_message )
178178
179179 @property
180180 def max_download_threads (self ) -> int :
@@ -246,14 +246,14 @@ def close_session(self, session_id: SessionId) -> None:
246246 session_id: The session identifier returned by open_session()
247247
248248 Raises:
249- ProgrammingError : If the session ID is invalid
249+ ValueError : If the session ID is invalid
250250 OperationalError: If there's an error closing the session
251251 """
252252
253253 logger .debug ("SeaDatabricksClient.close_session(session_id=%s)" , session_id )
254254
255255 if session_id .backend_type != BackendType .SEA :
256- raise ProgrammingError ("Not a valid SEA session ID" )
256+ raise ValueError ("Not a valid SEA session ID" )
257257 sea_session_id = session_id .to_sea_session_id ()
258258
259259 request_data = DeleteSessionRequest (
@@ -292,7 +292,7 @@ def get_allowed_session_configurations() -> List[str]:
292292
293293 def _extract_description_from_manifest (
294294 self , manifest : ResultManifest
295- ) -> Optional [ List ]:
295+ ) -> List [ Tuple ]:
296296 """
297297 Extract column description from a manifest object, in the format defined by
298298 the spec: https://peps.python.org/pep-0249/#description
@@ -301,15 +301,12 @@ def _extract_description_from_manifest(
301301 manifest: The ResultManifest object containing schema information
302302
303303 Returns:
304- Optional[ List]: A list of column tuples or None if no columns are found
304+ List[Tuple ]: A list of column tuples
305305 """
306306
307307 schema_data = manifest .schema
308308 columns_data = schema_data .get ("columns" , [])
309309
310- if not columns_data :
311- return None
312-
313310 columns = []
314311 for col_data in columns_data :
315312 # Format: (name, type_code, display_size, internal_size, precision, scale, null_ok)
@@ -325,7 +322,7 @@ def _extract_description_from_manifest(
325322 )
326323 )
327324
328- return columns if columns else None
325+ return columns
329326
330327 def _results_message_to_execute_response (
331328 self , response : GetStatementResponse
@@ -431,7 +428,7 @@ def execute_command(
431428 """
432429
433430 if session_id .backend_type != BackendType .SEA :
434- raise ProgrammingError ("Not a valid SEA session ID" )
431+ raise ValueError ("Not a valid SEA session ID" )
435432
436433 sea_session_id = session_id .to_sea_session_id ()
437434
@@ -506,13 +503,15 @@ def cancel_command(self, command_id: CommandId) -> None:
506503 command_id: Command identifier to cancel
507504
508505 Raises:
509- ProgrammingError : If the command ID is invalid
506+ ValueError : If the command ID is invalid
510507 """
511508
512509 if command_id .backend_type != BackendType .SEA :
513- raise ProgrammingError ("Not a valid SEA command ID" )
510+ raise ValueError ("Not a valid SEA command ID" )
514511
515512 sea_statement_id = command_id .to_sea_statement_id ()
513+ if sea_statement_id is None :
514+ raise ValueError ("Not a valid SEA command ID" )
516515
517516 request = CancelStatementRequest (statement_id = sea_statement_id )
518517 self .http_client ._make_request (
@@ -529,13 +528,15 @@ def close_command(self, command_id: CommandId) -> None:
529528 command_id: Command identifier to close
530529
531530 Raises:
532- ProgrammingError : If the command ID is invalid
531+ ValueError : If the command ID is invalid
533532 """
534533
535534 if command_id .backend_type != BackendType .SEA :
536- raise ProgrammingError ("Not a valid SEA command ID" )
535+ raise ValueError ("Not a valid SEA command ID" )
537536
538537 sea_statement_id = command_id .to_sea_statement_id ()
538+ if sea_statement_id is None :
539+ raise ValueError ("Not a valid SEA command ID" )
539540
540541 request = CloseStatementRequest (statement_id = sea_statement_id )
541542 self .http_client ._make_request (
@@ -555,13 +556,15 @@ def get_query_state(self, command_id: CommandId) -> CommandState:
555556 CommandState: The current state of the command
556557
557558 Raises:
558- ProgrammingError : If the command ID is invalid
559+ ValueError : If the command ID is invalid
559560 """
560561
561562 if command_id .backend_type != BackendType .SEA :
562- raise ProgrammingError ("Not a valid SEA command ID" )
563+ raise ValueError ("Not a valid SEA command ID" )
563564
564565 sea_statement_id = command_id .to_sea_statement_id ()
566+ if sea_statement_id is None :
567+ raise ValueError ("Not a valid SEA command ID" )
565568
566569 request = GetStatementRequest (statement_id = sea_statement_id )
567570 response_data = self .http_client ._make_request (
@@ -590,13 +593,15 @@ def get_execution_result(
590593 SeaResultSet: A SeaResultSet instance with the execution results
591594
592595 Raises:
593- ProgrammingError : If the command ID is invalid
596+ ValueError : If the command ID is invalid
594597 """
595598
596599 if command_id .backend_type != BackendType .SEA :
597- raise ProgrammingError ("Not a valid SEA command ID" )
600+ raise ValueError ("Not a valid SEA command ID" )
598601
599602 sea_statement_id = command_id .to_sea_statement_id ()
603+ if sea_statement_id is None :
604+ raise ValueError ("Not a valid SEA command ID" )
600605
601606 # Create the request model
602607 request = GetStatementRequest (statement_id = sea_statement_id )
@@ -610,7 +615,7 @@ def get_execution_result(
610615 response = GetStatementResponse .from_dict (response_data )
611616
612617 # Create and return a SeaResultSet
613- from databricks .sql .result_set import SeaResultSet
618+ from databricks .sql .backend . sea . result_set import SeaResultSet
614619
615620 execute_response = self ._results_message_to_execute_response (response )
616621
0 commit comments