27
27
BackendType ,
28
28
ExecuteResponse ,
29
29
)
30
- from databricks .sql .exc import DatabaseError , ServerOperationError
30
+ from databricks .sql .exc import DatabaseError , ProgrammingError , ServerOperationError
31
31
from databricks .sql .backend .sea .utils .http_client import SeaHttpClient
32
32
from databricks .sql .types import SSLOptions
33
33
@@ -172,7 +172,7 @@ def _extract_warehouse_id(self, http_path: str) -> str:
172
172
f"Note: SEA only works for warehouses."
173
173
)
174
174
logger .error (error_message )
175
- raise ValueError (error_message )
175
+ raise ProgrammingError (error_message )
176
176
177
177
@property
178
178
def max_download_threads (self ) -> int :
@@ -244,14 +244,14 @@ def close_session(self, session_id: SessionId) -> None:
244
244
session_id: The session identifier returned by open_session()
245
245
246
246
Raises:
247
- ValueError : If the session ID is invalid
247
+ ProgrammingError : If the session ID is invalid
248
248
OperationalError: If there's an error closing the session
249
249
"""
250
250
251
251
logger .debug ("SeaDatabricksClient.close_session(session_id=%s)" , session_id )
252
252
253
253
if session_id .backend_type != BackendType .SEA :
254
- raise ValueError ("Not a valid SEA session ID" )
254
+ raise ProgrammingError ("Not a valid SEA session ID" )
255
255
sea_session_id = session_id .to_sea_session_id ()
256
256
257
257
request_data = DeleteSessionRequest (
@@ -429,7 +429,7 @@ def execute_command(
429
429
"""
430
430
431
431
if session_id .backend_type != BackendType .SEA :
432
- raise ValueError ("Not a valid SEA session ID" )
432
+ raise ProgrammingError ("Not a valid SEA session ID" )
433
433
434
434
sea_session_id = session_id .to_sea_session_id ()
435
435
@@ -504,11 +504,11 @@ def cancel_command(self, command_id: CommandId) -> None:
504
504
command_id: Command identifier to cancel
505
505
506
506
Raises:
507
- ValueError : If the command ID is invalid
507
+ ProgrammingError : If the command ID is invalid
508
508
"""
509
509
510
510
if command_id .backend_type != BackendType .SEA :
511
- raise ValueError ("Not a valid SEA command ID" )
511
+ raise ProgrammingError ("Not a valid SEA command ID" )
512
512
513
513
sea_statement_id = command_id .to_sea_statement_id ()
514
514
@@ -527,11 +527,11 @@ def close_command(self, command_id: CommandId) -> None:
527
527
command_id: Command identifier to close
528
528
529
529
Raises:
530
- ValueError : If the command ID is invalid
530
+ ProgrammingError : If the command ID is invalid
531
531
"""
532
532
533
533
if command_id .backend_type != BackendType .SEA :
534
- raise ValueError ("Not a valid SEA command ID" )
534
+ raise ProgrammingError ("Not a valid SEA command ID" )
535
535
536
536
sea_statement_id = command_id .to_sea_statement_id ()
537
537
@@ -553,7 +553,7 @@ def get_query_state(self, command_id: CommandId) -> CommandState:
553
553
CommandState: The current state of the command
554
554
555
555
Raises:
556
- ValueError : If the command ID is invalid
556
+ ProgrammingError : If the command ID is invalid
557
557
"""
558
558
559
559
if command_id .backend_type != BackendType .SEA :
@@ -592,7 +592,7 @@ def get_execution_result(
592
592
"""
593
593
594
594
if command_id .backend_type != BackendType .SEA :
595
- raise ValueError ("Not a valid SEA command ID" )
595
+ raise ProgrammingError ("Not a valid SEA command ID" )
596
596
597
597
sea_statement_id = command_id .to_sea_statement_id ()
598
598
@@ -658,7 +658,7 @@ def get_schemas(
658
658
) -> SeaResultSet :
659
659
"""Get schemas by executing 'SHOW SCHEMAS IN catalog [LIKE pattern]'."""
660
660
if not catalog_name :
661
- raise ValueError ("Catalog name is required for get_schemas" )
661
+ raise DatabaseError ("Catalog name is required for get_schemas" )
662
662
663
663
operation = MetadataCommands .SHOW_SCHEMAS .value .format (catalog_name )
664
664
@@ -740,7 +740,7 @@ def get_columns(
740
740
) -> SeaResultSet :
741
741
"""Get columns by executing 'SHOW COLUMNS IN CATALOG catalog [SCHEMA LIKE pattern] [TABLE LIKE pattern] [LIKE pattern]'."""
742
742
if not catalog_name :
743
- raise ValueError ("Catalog name is required for get_columns" )
743
+ raise DatabaseError ("Catalog name is required for get_columns" )
744
744
745
745
operation = MetadataCommands .SHOW_COLUMNS .value .format (catalog_name )
746
746
0 commit comments