Skip to content

Commit 0b1eba5

Browse files
pass result_data instead of "initial links" into SeaCloudFetchQueue
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent c32b281 commit 0b1eba5

File tree

2 files changed

+8
-52
lines changed

2 files changed

+8
-52
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def build_queue(
6363
elif manifest.format == ResultFormat.ARROW_STREAM.value:
6464
# EXTERNAL_LINKS disposition
6565
return SeaCloudFetchQueue(
66-
initial_links=result_data.external_links or [],
66+
result_data=result_data,
6767
max_download_threads=max_download_threads,
6868
ssl_options=ssl_options,
6969
sea_client=sea_client,
@@ -103,7 +103,7 @@ class SeaCloudFetchQueue(CloudFetchQueue):
103103

104104
def __init__(
105105
self,
106-
initial_links: List["ExternalLink"],
106+
result_data: ResultData,
107107
max_download_threads: int,
108108
ssl_options: SSLOptions,
109109
sea_client: "SeaDatabricksClient",
@@ -144,8 +144,9 @@ def __init__(
144144
)
145145
)
146146

147-
initial_link = next((l for l in initial_links if l.chunk_index == 0), None)
148-
if not initial_link:
147+
initial_links = result_data.external_links or []
148+
first_link = next((l for l in initial_links if l.chunk_index == 0), None)
149+
if not first_link:
149150
return
150151

151152
self.download_manager = ResultFileDownloadManager(
@@ -156,7 +157,7 @@ def __init__(
156157
)
157158

158159
# Track the current chunk we're processing
159-
self._current_chunk_link = initial_link
160+
self._current_chunk_link = first_link
160161

161162
# Initialize table and position
162163
self.table = self._create_table_from_link(self._current_chunk_link)

tests/unit/test_sea_queue.py

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def test_init_with_valid_initial_link(
348348
SeaCloudFetchQueue, "_create_table_from_link", return_value=None
349349
):
350350
queue = SeaCloudFetchQueue(
351-
initial_links=[sample_external_link],
351+
result_data=ResultData(external_links=[sample_external_link]),
352352
max_download_threads=5,
353353
ssl_options=ssl_options,
354354
sea_client=mock_sea_client,
@@ -386,7 +386,7 @@ def test_init_no_initial_links(
386386
"""Test initialization with no initial links."""
387387
# Create a queue with empty initial links
388388
queue = SeaCloudFetchQueue(
389-
initial_links=[],
389+
result_data=ResultData(external_links=[]),
390390
max_download_threads=5,
391391
ssl_options=ssl_options,
392392
sea_client=mock_sea_client,
@@ -413,51 +413,6 @@ def test_init_no_initial_links(
413413
or queue._current_chunk_link is None
414414
)
415415

416-
@patch("databricks.sql.backend.sea.queue.ResultFileDownloadManager")
417-
@patch("databricks.sql.backend.sea.queue.logger")
418-
def test_init_non_zero_chunk_index(
419-
self,
420-
mock_logger,
421-
mock_download_manager_class,
422-
mock_sea_client,
423-
ssl_options,
424-
description,
425-
):
426-
"""Test initialization with non-zero chunk index initial link."""
427-
# Create a link with chunk_index != 0
428-
non_zero_link = ExternalLink(
429-
external_link="https://example.com/data/chunk1",
430-
expiration="2025-07-03T05:51:18.118009",
431-
row_count=100,
432-
byte_count=1024,
433-
row_offset=100,
434-
chunk_index=1,
435-
next_chunk_index=2,
436-
http_headers={"Authorization": "Bearer token123"},
437-
)
438-
439-
# Create a queue with non-zero chunk index
440-
queue = SeaCloudFetchQueue(
441-
initial_links=[non_zero_link],
442-
max_download_threads=5,
443-
ssl_options=ssl_options,
444-
sea_client=mock_sea_client,
445-
statement_id="test-statement-123",
446-
total_chunk_count=1,
447-
lz4_compressed=False,
448-
description=description,
449-
)
450-
451-
# Verify debug message was logged
452-
mock_logger.debug.assert_called_with(
453-
"SeaCloudFetchQueue: Initialize CloudFetch loader for statement {}, total chunks: {}".format(
454-
"test-statement-123", 1
455-
)
456-
)
457-
458-
# Verify download manager wasn't created (no chunk 0)
459-
mock_download_manager_class.assert_not_called()
460-
461416
@patch("databricks.sql.backend.sea.queue.logger")
462417
def test_progress_chunk_link_no_current_link(self, mock_logger):
463418
"""Test _progress_chunk_link with no current link."""

0 commit comments

Comments
 (0)