5
5
import re
6
6
from typing import Any , Dict , Tuple , List , Optional , Union , TYPE_CHECKING , Set
7
7
8
- from databricks .sql .backend .sea .models .base import ExternalLink , ResultManifest
8
+ from databricks .sql .backend .sea .models .base import ResultManifest
9
9
from databricks .sql .backend .sea .utils .constants import (
10
10
ALLOWED_SESSION_CONF_TO_DEFAULT_VALUES_MAP ,
11
11
ResultFormat ,
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
45
45
GetStatementResponse ,
46
46
CreateSessionResponse ,
47
47
)
48
- from databricks .sql .backend .sea .models .responses import GetChunksResponse
49
48
50
49
logger = logging .getLogger (__name__ )
51
50
@@ -90,7 +89,6 @@ class SeaDatabricksClient(DatabricksClient):
90
89
STATEMENT_PATH = BASE_PATH + "statements"
91
90
STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}"
92
91
CANCEL_STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}/cancel"
93
- CHUNK_PATH_WITH_ID_AND_INDEX = STATEMENT_PATH + "/{}/result/chunks/{}"
94
92
95
93
# SEA constants
96
94
POLL_INTERVAL_SECONDS = 0.2
@@ -137,13 +135,13 @@ def __init__(
137
135
self .warehouse_id = self ._extract_warehouse_id (http_path )
138
136
139
137
# Initialize HTTP client
140
- self ._http_client = SeaHttpClient (
138
+ self .http_client = SeaHttpClient (
141
139
server_hostname = server_hostname ,
142
140
port = port ,
143
141
http_path = http_path ,
144
142
http_headers = http_headers ,
145
143
auth_provider = auth_provider ,
146
- ssl_options = self . _ssl_options ,
144
+ ssl_options = ssl_options ,
147
145
** kwargs ,
148
146
)
149
147
@@ -182,7 +180,7 @@ def _extract_warehouse_id(self, http_path: str) -> str:
182
180
f"Note: SEA only works for warehouses."
183
181
)
184
182
logger .error (error_message )
185
- raise ValueError (error_message )
183
+ raise ProgrammingError (error_message )
186
184
187
185
@property
188
186
def max_download_threads (self ) -> int :
@@ -229,7 +227,7 @@ def open_session(
229
227
schema = schema ,
230
228
)
231
229
232
- response = self ._http_client ._make_request (
230
+ response = self .http_client ._make_request (
233
231
method = "POST" , path = self .SESSION_PATH , data = request_data .to_dict ()
234
232
)
235
233
@@ -254,7 +252,7 @@ def close_session(self, session_id: SessionId) -> None:
254
252
session_id: The session identifier returned by open_session()
255
253
256
254
Raises:
257
- ValueError : If the session ID is invalid
255
+ ProgrammingError : If the session ID is invalid
258
256
OperationalError: If there's an error closing the session
259
257
"""
260
258
@@ -269,7 +267,7 @@ def close_session(self, session_id: SessionId) -> None:
269
267
session_id = sea_session_id ,
270
268
)
271
269
272
- self ._http_client ._make_request (
270
+ self .http_client ._make_request (
273
271
method = "DELETE" ,
274
272
path = self .SESSION_PATH_WITH_ID .format (sea_session_id ),
275
273
data = request_data .to_dict (),
@@ -351,7 +349,7 @@ def _results_message_to_execute_response(
351
349
352
350
# Check for compression
353
351
lz4_compressed = (
354
- response .manifest .result_compression == ResultCompression .LZ4_FRAME . value
352
+ response .manifest .result_compression == ResultCompression .LZ4_FRAME
355
353
)
356
354
357
355
execute_response = ExecuteResponse (
@@ -457,7 +455,7 @@ def execute_command(
457
455
enforce_embedded_schema_correctness: Whether to enforce schema correctness
458
456
459
457
Returns:
460
- SeaResultSet : A SeaResultSet instance for the executed command
458
+ ResultSet : A SeaResultSet instance for the executed command
461
459
"""
462
460
463
461
if session_id .backend_type != BackendType .SEA :
@@ -508,7 +506,7 @@ def execute_command(
508
506
result_compression = result_compression ,
509
507
)
510
508
511
- response_data = self ._http_client ._make_request (
509
+ response_data = self .http_client ._make_request (
512
510
method = "POST" , path = self .STATEMENT_PATH , data = request .to_dict ()
513
511
)
514
512
response = ExecuteStatementResponse .from_dict (response_data )
@@ -545,7 +543,7 @@ def cancel_command(self, command_id: CommandId) -> None:
545
543
command_id: Command identifier to cancel
546
544
547
545
Raises:
548
- ValueError : If the command ID is invalid
546
+ ProgrammingError : If the command ID is invalid
549
547
"""
550
548
551
549
if command_id .backend_type != BackendType .SEA :
@@ -556,7 +554,7 @@ def cancel_command(self, command_id: CommandId) -> None:
556
554
raise ValueError ("Not a valid SEA command ID" )
557
555
558
556
request = CancelStatementRequest (statement_id = sea_statement_id )
559
- self ._http_client ._make_request (
557
+ self .http_client ._make_request (
560
558
method = "POST" ,
561
559
path = self .CANCEL_STATEMENT_PATH_WITH_ID .format (sea_statement_id ),
562
560
data = request .to_dict (),
@@ -570,7 +568,7 @@ def close_command(self, command_id: CommandId) -> None:
570
568
command_id: Command identifier to close
571
569
572
570
Raises:
573
- ValueError : If the command ID is invalid
571
+ ProgrammingError : If the command ID is invalid
574
572
"""
575
573
576
574
if command_id .backend_type != BackendType .SEA :
@@ -581,7 +579,7 @@ def close_command(self, command_id: CommandId) -> None:
581
579
raise ValueError ("Not a valid SEA command ID" )
582
580
583
581
request = CloseStatementRequest (statement_id = sea_statement_id )
584
- self ._http_client ._make_request (
582
+ self .http_client ._make_request (
585
583
method = "DELETE" ,
586
584
path = self .STATEMENT_PATH_WITH_ID .format (sea_statement_id ),
587
585
data = request .to_dict (),
@@ -600,7 +598,7 @@ def _poll_query(self, command_id: CommandId) -> GetStatementResponse:
600
598
raise ValueError ("Not a valid SEA command ID" )
601
599
602
600
request = GetStatementRequest (statement_id = sea_statement_id )
603
- response_data = self ._http_client ._make_request (
601
+ response_data = self .http_client ._make_request (
604
602
method = "GET" ,
605
603
path = self .STATEMENT_PATH_WITH_ID .format (sea_statement_id ),
606
604
data = request .to_dict (),
0 commit comments