Skip to content

Commit 7ea7b75

Browse files
remove un-necessary Optional params
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 6ec8656 commit 7ea7b75

File tree

3 files changed

+16
-66
lines changed

3 files changed

+16
-66
lines changed

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

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ def build_queue(
3535
result_data: ResultData,
3636
manifest: ResultManifest,
3737
statement_id: str,
38-
ssl_options: Optional[SSLOptions] = None,
39-
description: List[Tuple] = [],
40-
max_download_threads: Optional[int] = None,
41-
sea_client: Optional[SeaDatabricksClient] = None,
42-
lz4_compressed: bool = False,
38+
ssl_options: SSLOptions,
39+
description: List[Tuple],
40+
max_download_threads: int,
41+
sea_client: SeaDatabricksClient,
42+
lz4_compressed: bool,
4343
) -> ResultSetQueue:
4444
"""
4545
Factory method to build a result set queue for SEA backend.
@@ -62,19 +62,6 @@ def build_queue(
6262
return JsonQueue(result_data.data)
6363
elif manifest.format == ResultFormat.ARROW_STREAM.value:
6464
# EXTERNAL_LINKS disposition
65-
if not max_download_threads:
66-
raise ValueError(
67-
"Max download threads is required for EXTERNAL_LINKS disposition"
68-
)
69-
if not ssl_options:
70-
raise ValueError(
71-
"SSL options are required for EXTERNAL_LINKS disposition"
72-
)
73-
if not sea_client:
74-
raise ValueError(
75-
"SEA client is required for EXTERNAL_LINKS disposition"
76-
)
77-
7865
return SeaCloudFetchQueue(
7966
initial_links=result_data.external_links or [],
8067
max_download_threads=max_download_threads,

src/databricks/sql/utils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ def next_n_rows(self, num_rows: int) -> "pyarrow.Table":
261261
length = min(num_rows, self.table.num_rows - self.table_row_index)
262262
table_slice = self.table.slice(self.table_row_index, length)
263263
results = pyarrow.concat_tables([results, table_slice])
264-
265264
self.table_row_index += table_slice.num_rows
266265

267266
# Replace current table with the next table if we are at the end of the current table
@@ -284,21 +283,19 @@ def remaining_rows(self) -> "pyarrow.Table":
284283
if not self.table:
285284
# Return empty pyarrow table to cause retry of fetch
286285
return self._create_empty_table()
287-
288286
results = self.table.slice(0, 0)
289287
while self.table:
290288
table_slice = self.table.slice(
291289
self.table_row_index, self.table.num_rows - self.table_row_index
292290
)
293291
results = pyarrow.concat_tables([results, table_slice])
294-
295292
self.table_row_index += table_slice.num_rows
296293
self.table = self._create_next_table()
297294
self.table_row_index = 0
298295
return results
299296

300297
def _create_table_at_offset(self, offset: int) -> Union["pyarrow.Table", None]:
301-
"""Create next table by retrieving the logical next downloaded file."""
298+
"""Create next table at the given row offset"""
302299
# Create next table by retrieving the logical next downloaded file, or return None to signal end of queue
303300
if not self.download_manager:
304301
logger.debug("CloudFetchQueue: No download manager available")
@@ -311,7 +308,6 @@ def _create_table_at_offset(self, offset: int) -> Union["pyarrow.Table", None]:
311308
)
312309
# None signals no more Arrow tables can be built from the remaining handlers if any remain
313310
return None
314-
315311
arrow_table = create_arrow_table_from_arrow_file(
316312
downloaded_file.file_bytes, self.description
317313
)

tests/unit/test_sea_queue.py

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ def test_build_queue_json_array(self, json_manifest, sample_data):
183183
result_data=result_data,
184184
manifest=json_manifest,
185185
statement_id="test-statement",
186+
ssl_options=SSLOptions(),
187+
description=[],
188+
max_download_threads=10,
189+
sea_client=Mock(),
190+
lz4_compressed=False,
186191
)
187192

188193
assert isinstance(queue, JsonQueue)
@@ -222,49 +227,6 @@ def test_build_queue_arrow_stream(
222227

223228
assert isinstance(queue, SeaCloudFetchQueue)
224229

225-
def test_build_queue_arrow_stream_missing_threads(
226-
self, arrow_manifest, ssl_options, mock_sea_client
227-
):
228-
"""Test building an Arrow stream queue with missing max_download_threads."""
229-
result_data = ResultData(data=None, external_links=[])
230-
231-
with pytest.raises(ValueError, match="Max download threads is required"):
232-
SeaResultSetQueueFactory.build_queue(
233-
result_data=result_data,
234-
manifest=arrow_manifest,
235-
statement_id="test-statement",
236-
ssl_options=ssl_options,
237-
sea_client=mock_sea_client,
238-
)
239-
240-
def test_build_queue_arrow_stream_missing_ssl(
241-
self, arrow_manifest, mock_sea_client
242-
):
243-
"""Test building an Arrow stream queue with missing SSL options."""
244-
result_data = ResultData(data=None, external_links=[])
245-
246-
with pytest.raises(ValueError, match="SSL options are required"):
247-
SeaResultSetQueueFactory.build_queue(
248-
result_data=result_data,
249-
manifest=arrow_manifest,
250-
statement_id="test-statement",
251-
max_download_threads=10,
252-
sea_client=mock_sea_client,
253-
)
254-
255-
def test_build_queue_arrow_stream_missing_client(self, arrow_manifest, ssl_options):
256-
"""Test building an Arrow stream queue with missing SEA client."""
257-
result_data = ResultData(data=None, external_links=[])
258-
259-
with pytest.raises(ValueError, match="SEA client is required"):
260-
SeaResultSetQueueFactory.build_queue(
261-
result_data=result_data,
262-
manifest=arrow_manifest,
263-
statement_id="test-statement",
264-
ssl_options=ssl_options,
265-
max_download_threads=10,
266-
)
267-
268230
def test_build_queue_invalid_format(self, invalid_manifest):
269231
"""Test building a queue with invalid format."""
270232
result_data = ResultData(data=[])
@@ -274,6 +236,11 @@ def test_build_queue_invalid_format(self, invalid_manifest):
274236
result_data=result_data,
275237
manifest=invalid_manifest,
276238
statement_id="test-statement",
239+
ssl_options=SSLOptions(),
240+
description=[],
241+
max_download_threads=10,
242+
sea_client=Mock(),
243+
lz4_compressed=False,
277244
)
278245

279246

0 commit comments

Comments
 (0)