@@ -156,10 +156,10 @@ def __init__(
156156 )
157157
158158 # Track the current chunk we're processing
159- self ._current_chunk_link : Optional [ "ExternalLink" ] = initial_link
159+ self ._current_chunk_link = initial_link
160160
161161 # Initialize table and position
162- self .table = self ._create_next_table ( )
162+ self .table = self ._create_table_from_link ( self . _current_chunk_link )
163163
164164 def _convert_to_thrift_link (self , link : "ExternalLink" ) -> TSparkArrowResultLink :
165165 """Convert SEA external links to Thrift format for compatibility with existing download manager."""
@@ -202,22 +202,30 @@ def _progress_chunk_link(self):
202202 f"SeaCloudFetchQueue: Progressed to link for chunk { next_chunk_index } : { self ._current_chunk_link } "
203203 )
204204
205- def _create_next_table (self ) -> Union ["pyarrow.Table" , None ]:
206- """Create next table by retrieving the logical next downloaded file."""
207- if not self ._current_chunk_link :
208- logger .debug ("SeaCloudFetchQueue: No current chunk link, returning" )
209- return None
205+ def _create_table_from_link (
206+ self , link : "ExternalLink"
207+ ) -> Union ["pyarrow.Table" , None ]:
208+ """Create a table from a link."""
210209
211210 if not self .download_manager :
212211 logger .debug ("SeaCloudFetchQueue: No download manager, returning" )
213212 return None
214213
215- thrift_link = self ._convert_to_thrift_link (self . _current_chunk_link )
214+ thrift_link = self ._convert_to_thrift_link (link )
216215 self .download_manager .add_link (thrift_link )
217216
218- row_offset = self . _current_chunk_link .row_offset
217+ row_offset = link .row_offset
219218 arrow_table = self ._create_table_at_offset (row_offset )
220219
220+ return arrow_table
221+
222+ def _create_next_table (self ) -> Union ["pyarrow.Table" , None ]:
223+ """Create next table by retrieving the logical next downloaded file."""
224+
221225 self ._progress_chunk_link ()
222226
223- return arrow_table
227+ if not self ._current_chunk_link :
228+ logger .debug ("SeaCloudFetchQueue: No current chunk link, returning" )
229+ return None
230+
231+ return self ._create_table_from_link (self ._current_chunk_link )
0 commit comments