55import re
66from typing import Any ,Dict ,Tuple ,List ,Optional ,Union ,TYPE_CHECKING ,Set
77
8- from databricks .sql .backend .sea .models .base import ExternalLink , ResultManifest
8+ from databricks .sql .backend .sea .models .base import ResultManifest
99from databricks .sql .backend .sea .utils .constants import (
1010ALLOWED_SESSION_CONF_TO_DEFAULT_VALUES_MAP ,
1111ResultFormat ,
2929BackendType ,
3030ExecuteResponse ,
3131)
32- from databricks .sql .exc import DatabaseError ,ServerOperationError
32+ from databricks .sql .exc import DatabaseError ,ProgrammingError , ServerOperationError
3333from databricks .sql .backend .sea .utils .http_client import SeaHttpClient
3434from databricks .sql .types import SSLOptions
3535
4545GetStatementResponse ,
4646CreateSessionResponse ,
4747)
48- from databricks .sql .backend .sea .models .responses import GetChunksResponse
4948
5049logger = logging .getLogger (__name__ )
5150
@@ -90,7 +89,6 @@ class SeaDatabricksClient(DatabricksClient):
9089STATEMENT_PATH = BASE_PATH + "statements"
9190STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}"
9291CANCEL_STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}/cancel"
93- CHUNK_PATH_WITH_ID_AND_INDEX = STATEMENT_PATH + "/{}/result/chunks/{}"
9492
9593# SEA constants
9694POLL_INTERVAL_SECONDS = 0.2
@@ -137,13 +135,13 @@ def __init__(
137135self .warehouse_id = self ._extract_warehouse_id (http_path )
138136
139137# Initialize HTTP client
140- self ._http_client = SeaHttpClient (
138+ self .http_client = SeaHttpClient (
141139server_hostname = server_hostname ,
142140port = port ,
143141http_path = http_path ,
144142http_headers = http_headers ,
145143auth_provider = auth_provider ,
146- ssl_options = self . _ssl_options ,
144+ ssl_options = ssl_options ,
147145** kwargs ,
148146 )
149147
@@ -182,7 +180,7 @@ def _extract_warehouse_id(self, http_path: str) -> str:
182180f"Note: SEA only works for warehouses."
183181 )
184182logger .error (error_message )
185- raise ValueError (error_message )
183+ raise ProgrammingError (error_message )
186184
187185@property
188186def max_download_threads (self )-> int :
@@ -229,7 +227,7 @@ def open_session(
229227schema = schema ,
230228 )
231229
232- response = self ._http_client ._make_request (
230+ response = self .http_client ._make_request (
233231method = "POST" ,path = self .SESSION_PATH ,data = request_data .to_dict ()
234232 )
235233
@@ -254,7 +252,7 @@ def close_session(self, session_id: SessionId) -> None:
254252 session_id: The session identifier returned by open_session()
255253
256254 Raises:
257- ValueError : If the session ID is invalid
255+ ProgrammingError : If the session ID is invalid
258256 OperationalError: If there's an error closing the session
259257 """
260258
@@ -269,7 +267,7 @@ def close_session(self, session_id: SessionId) -> None:
269267session_id = sea_session_id ,
270268 )
271269
272- self ._http_client ._make_request (
270+ self .http_client ._make_request (
273271method = "DELETE" ,
274272path = self .SESSION_PATH_WITH_ID .format (sea_session_id ),
275273data = request_data .to_dict (),
@@ -351,7 +349,7 @@ def _results_message_to_execute_response(
351349
352350# Check for compression
353351lz4_compressed = (
354- response .manifest .result_compression == ResultCompression .LZ4_FRAME . value
352+ response .manifest .result_compression == ResultCompression .LZ4_FRAME
355353 )
356354
357355execute_response = ExecuteResponse (
@@ -457,7 +455,7 @@ def execute_command(
457455 enforce_embedded_schema_correctness: Whether to enforce schema correctness
458456
459457 Returns:
460- SeaResultSet : A SeaResultSet instance for the executed command
458+ ResultSet : A SeaResultSet instance for the executed command
461459 """
462460
463461if session_id .backend_type != BackendType .SEA :
@@ -508,7 +506,7 @@ def execute_command(
508506result_compression = result_compression ,
509507 )
510508
511- response_data = self ._http_client ._make_request (
509+ response_data = self .http_client ._make_request (
512510method = "POST" ,path = self .STATEMENT_PATH ,data = request .to_dict ()
513511 )
514512response = ExecuteStatementResponse .from_dict (response_data )
@@ -545,7 +543,7 @@ def cancel_command(self, command_id: CommandId) -> None:
545543 command_id: Command identifier to cancel
546544
547545 Raises:
548- ValueError : If the command ID is invalid
546+ ProgrammingError : If the command ID is invalid
549547 """
550548
551549if command_id .backend_type != BackendType .SEA :
@@ -556,7 +554,7 @@ def cancel_command(self, command_id: CommandId) -> None:
556554raise ValueError ("Not a valid SEA command ID" )
557555
558556request = CancelStatementRequest (statement_id = sea_statement_id )
559- self ._http_client ._make_request (
557+ self .http_client ._make_request (
560558method = "POST" ,
561559path = self .CANCEL_STATEMENT_PATH_WITH_ID .format (sea_statement_id ),
562560data = request .to_dict (),
@@ -570,7 +568,7 @@ def close_command(self, command_id: CommandId) -> None:
570568 command_id: Command identifier to close
571569
572570 Raises:
573- ValueError : If the command ID is invalid
571+ ProgrammingError : If the command ID is invalid
574572 """
575573
576574if command_id .backend_type != BackendType .SEA :
@@ -581,7 +579,7 @@ def close_command(self, command_id: CommandId) -> None:
581579raise ValueError ("Not a valid SEA command ID" )
582580
583581request = CloseStatementRequest (statement_id = sea_statement_id )
584- self ._http_client ._make_request (
582+ self .http_client ._make_request (
585583method = "DELETE" ,
586584path = self .STATEMENT_PATH_WITH_ID .format (sea_statement_id ),
587585data = request .to_dict (),
@@ -600,7 +598,7 @@ def _poll_query(self, command_id: CommandId) -> GetStatementResponse:
600598raise ValueError ("Not a valid SEA command ID" )
601599
602600request = GetStatementRequest (statement_id = sea_statement_id )
603- response_data = self ._http_client ._make_request (
601+ response_data = self .http_client ._make_request (
604602method = "GET" ,
605603path = self .STATEMENT_PATH_WITH_ID .format (sea_statement_id ),
606604data = request .to_dict (),