Skip to content

Commit e1842d8

Browse files
fix type errors (ssl_options, CHUNK_PATH_WITH_ID..., etc.)
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 03cdc4f commit e1842d8

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

src/databricks/sql/backend/sea/backend.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import re
55
from typing import Dict, Tuple, List, Optional, Any, Union, TYPE_CHECKING, Set
66

7+
from databricks.sql.backend.sea.models.base import ExternalLink
78
from databricks.sql.backend.sea.utils.constants import (
89
ALLOWED_SESSION_CONF_TO_DEFAULT_VALUES_MAP,
910
ResultFormat,
@@ -91,6 +92,7 @@ class SeaDatabricksClient(DatabricksClient):
9192
STATEMENT_PATH = BASE_PATH + "statements"
9293
STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}"
9394
CANCEL_STATEMENT_PATH_WITH_ID = STATEMENT_PATH + "/{}/cancel"
95+
CHUNK_PATH_WITH_ID_AND_INDEX = STATEMENT_PATH + "/{}/result/chunks/{}"
9496

9597
def __init__(
9698
self,
@@ -326,7 +328,7 @@ def _extract_description_from_manifest(self, manifest_obj) -> Optional[List]:
326328

327329
return columns if columns else None
328330

329-
def get_chunk_link(self, statement_id: str, chunk_index: int) -> "ExternalLink":
331+
def get_chunk_link(self, statement_id: str, chunk_index: int) -> ExternalLink:
330332
"""
331333
Get links for chunks starting from the specified index.
332334
@@ -347,7 +349,13 @@ def get_chunk_link(self, statement_id: str, chunk_index: int) -> "ExternalLink":
347349
links = response.external_links
348350
link = next((l for l in links if l.chunk_index == chunk_index), None)
349351
if not link:
350-
raise Error(f"No link found for chunk index {chunk_index}")
352+
raise ServerOperationError(
353+
f"No link found for chunk index {chunk_index}",
354+
{
355+
"operation-id": statement_id,
356+
"diagnostic-info": None,
357+
},
358+
)
351359

352360
return link
353361

src/databricks/sql/result_set.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ def __init__(
488488
result_data,
489489
manifest,
490490
str(execute_response.command_id.to_sea_statement_id()),
491+
ssl_options=self.connection.session.ssl_options,
491492
description=execute_response.description,
492493
max_download_threads=sea_client.max_download_threads,
493494
sea_client=sea_client,
@@ -512,27 +513,6 @@ def __init__(
512513
# Initialize queue for result data if not provided
513514
self.results = results_queue or JsonQueue([])
514515

515-
def fetchmany_arrow(self, size: int) -> "pyarrow.Table":
516-
"""
517-
Fetch the next set of rows as an Arrow table.
518-
519-
Args:
520-
size: Number of rows to fetch
521-
522-
Returns:
523-
PyArrow Table containing the fetched rows
524-
525-
Raises:
526-
ImportError: If PyArrow is not installed
527-
ValueError: If size is negative
528-
"""
529-
if size < 0:
530-
raise ValueError(f"size argument for fetchmany is {size} but must be >= 0")
531-
532-
results = self.results.next_n_rows(size)
533-
n_remaining_rows = size - results.num_rows
534-
self._next_row_index += results.num_rows
535-
536516
def fetchmany_json(self, size: int):
537517
"""
538518
Fetch the next set of rows as a columnar table.

src/databricks/sql/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(
6464
base_headers = [("User-Agent", useragent_header)]
6565
all_headers = (http_headers or []) + base_headers
6666

67-
self._ssl_options = SSLOptions(
67+
self.ssl_options = SSLOptions(
6868
# Double negation is generally a bad thing, but we have to keep backward compatibility
6969
tls_verify=not kwargs.get(
7070
"_tls_no_verify", False
@@ -113,7 +113,7 @@ def _create_backend(
113113
"http_path": http_path,
114114
"http_headers": all_headers,
115115
"auth_provider": auth_provider,
116-
"ssl_options": self._ssl_options,
116+
"ssl_options": self.ssl_options,
117117
"_use_arrow_native_complex_types": _use_arrow_native_complex_types,
118118
**kwargs,
119119
}

src/databricks/sql/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def build_queue(
131131
sea_result_data: ResultData,
132132
manifest: Optional[ResultManifest],
133133
statement_id: str,
134+
ssl_options: Optional[SSLOptions] = None,
134135
description: Optional[List[Tuple[Any, ...]]] = None,
135136
max_download_threads: Optional[int] = None,
136137
sea_client: Optional["SeaDatabricksClient"] = None,

0 commit comments

Comments
 (0)