29
29
BackendType ,
30
30
ExecuteResponse ,
31
31
)
32
- from databricks .sql .exc import DatabaseError , ServerOperationError
32
+ from databricks .sql .exc import DatabaseError , ProgrammingError , ServerOperationError
33
33
from databricks .sql .backend .sea .utils .http_client import SeaHttpClient
34
34
from databricks .sql .types import SSLOptions
35
35
@@ -152,7 +152,7 @@ def _extract_warehouse_id(self, http_path: str) -> str:
152
152
The extracted warehouse ID
153
153
154
154
Raises:
155
- ValueError : If the warehouse ID cannot be extracted from the path
155
+ ProgrammingError : If the warehouse ID cannot be extracted from the path
156
156
"""
157
157
158
158
warehouse_pattern = re .compile (r".*/warehouses/(.+)" )
@@ -176,7 +176,7 @@ def _extract_warehouse_id(self, http_path: str) -> str:
176
176
f"Note: SEA only works for warehouses."
177
177
)
178
178
logger .error (error_message )
179
- raise ValueError (error_message )
179
+ raise ProgrammingError (error_message )
180
180
181
181
@property
182
182
def max_download_threads (self ) -> int :
@@ -248,14 +248,14 @@ def close_session(self, session_id: SessionId) -> None:
248
248
session_id: The session identifier returned by open_session()
249
249
250
250
Raises:
251
- ValueError : If the session ID is invalid
251
+ ProgrammingError : If the session ID is invalid
252
252
OperationalError: If there's an error closing the session
253
253
"""
254
254
255
255
logger .debug ("SeaDatabricksClient.close_session(session_id=%s)" , session_id )
256
256
257
257
if session_id .backend_type != BackendType .SEA :
258
- raise ValueError ("Not a valid SEA session ID" )
258
+ raise ProgrammingError ("Not a valid SEA session ID" )
259
259
sea_session_id = session_id .to_sea_session_id ()
260
260
261
261
request_data = DeleteSessionRequest (
@@ -433,7 +433,7 @@ def execute_command(
433
433
"""
434
434
435
435
if session_id .backend_type != BackendType .SEA :
436
- raise ValueError ("Not a valid SEA session ID" )
436
+ raise ProgrammingError ("Not a valid SEA session ID" )
437
437
438
438
sea_session_id = session_id .to_sea_session_id ()
439
439
@@ -508,11 +508,11 @@ def cancel_command(self, command_id: CommandId) -> None:
508
508
command_id: Command identifier to cancel
509
509
510
510
Raises:
511
- ValueError : If the command ID is invalid
511
+ ProgrammingError : If the command ID is invalid
512
512
"""
513
513
514
514
if command_id .backend_type != BackendType .SEA :
515
- raise ValueError ("Not a valid SEA command ID" )
515
+ raise ProgrammingError ("Not a valid SEA command ID" )
516
516
517
517
sea_statement_id = command_id .to_sea_statement_id ()
518
518
@@ -531,11 +531,11 @@ def close_command(self, command_id: CommandId) -> None:
531
531
command_id: Command identifier to close
532
532
533
533
Raises:
534
- ValueError : If the command ID is invalid
534
+ ProgrammingError : If the command ID is invalid
535
535
"""
536
536
537
537
if command_id .backend_type != BackendType .SEA :
538
- raise ValueError ("Not a valid SEA command ID" )
538
+ raise ProgrammingError ("Not a valid SEA command ID" )
539
539
540
540
sea_statement_id = command_id .to_sea_statement_id ()
541
541
@@ -557,11 +557,11 @@ def get_query_state(self, command_id: CommandId) -> CommandState:
557
557
CommandState: The current state of the command
558
558
559
559
Raises:
560
- ValueError : If the command ID is invalid
560
+ ProgrammingError : If the command ID is invalid
561
561
"""
562
562
563
563
if command_id .backend_type != BackendType .SEA :
564
- raise ValueError ("Not a valid SEA command ID" )
564
+ raise ProgrammingError ("Not a valid SEA command ID" )
565
565
566
566
sea_statement_id = command_id .to_sea_statement_id ()
567
567
@@ -592,11 +592,11 @@ def get_execution_result(
592
592
SeaResultSet: A SeaResultSet instance with the execution results
593
593
594
594
Raises:
595
- ValueError : If the command ID is invalid
595
+ ProgrammingError : If the command ID is invalid
596
596
"""
597
597
598
598
if command_id .backend_type != BackendType .SEA :
599
- raise ValueError ("Not a valid SEA command ID" )
599
+ raise ProgrammingError ("Not a valid SEA command ID" )
600
600
601
601
sea_statement_id = command_id .to_sea_statement_id ()
602
602
@@ -691,7 +691,7 @@ def get_schemas(
691
691
) -> SeaResultSet :
692
692
"""Get schemas by executing 'SHOW SCHEMAS IN catalog [LIKE pattern]'."""
693
693
if not catalog_name :
694
- raise ValueError ("Catalog name is required for get_schemas" )
694
+ raise DatabaseError ("Catalog name is required for get_schemas" )
695
695
696
696
operation = MetadataCommands .SHOW_SCHEMAS .value .format (catalog_name )
697
697
@@ -773,7 +773,7 @@ def get_columns(
773
773
) -> SeaResultSet :
774
774
"""Get columns by executing 'SHOW COLUMNS IN CATALOG catalog [SCHEMA LIKE pattern] [TABLE LIKE pattern] [LIKE pattern]'."""
775
775
if not catalog_name :
776
- raise ValueError ("Catalog name is required for get_columns" )
776
+ raise DatabaseError ("Catalog name is required for get_columns" )
777
777
778
778
operation = MetadataCommands .SHOW_COLUMNS .value .format (catalog_name )
779
779
0 commit comments