Skip to content

Commit 9ddb3ec

Browse files
simplify remaining_rows fetch
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 75d5bc1 commit 9ddb3ec

File tree

1 file changed

+7
-39
lines changed

1 file changed

+7
-39
lines changed

src/databricks/sql/cloud_fetch_queue.py

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -387,62 +387,30 @@ def _fetch_chunk_link(self, chunk_index: int) -> Optional["ExternalLink"]:
387387
return link
388388

389389
def remaining_rows(self) -> "pyarrow.Table":
390-
"""Get all remaining rows of the cloud fetch Arrow dataframes."""
390+
"""
391+
Get all remaining rows of the cloud fetch Arrow dataframes.
392+
393+
Returns:
394+
pyarrow.Table
395+
"""
391396
if not self.table:
392397
# Return empty pyarrow table to cause retry of fetch
393-
logger.info("SeaCloudFetchQueue: No table available, returning empty table")
394398
return self._create_empty_table()
395399

396-
logger.info("SeaCloudFetchQueue: Retrieving all remaining rows")
397400
results = pyarrow.Table.from_pydict({}) # Empty table
398-
total_rows_fetched = 0
399-
400401
while self.table:
401402
table_slice = self.table.slice(
402403
self.table_row_index, self.table.num_rows - self.table_row_index
403404
)
404-
logger.info(
405-
"SeaCloudFetchQueue: Got slice of {} rows from current table (from index {})".format(
406-
table_slice.num_rows, self.table_row_index
407-
)
408-
)
409-
410405
if results.num_rows > 0:
411-
logger.info(
412-
"SeaCloudFetchQueue: Concatenating {} rows to existing {} rows".format(
413-
table_slice.num_rows, results.num_rows
414-
)
415-
)
416406
results = pyarrow.concat_tables([results, table_slice])
417407
else:
418408
results = table_slice
419409

420410
self.table_row_index += table_slice.num_rows
421-
total_rows_fetched += table_slice.num_rows
422-
423-
logger.info(
424-
"SeaCloudFetchQueue: After slice, table_row_index={}, total_rows_fetched={}".format(
425-
self.table_row_index, total_rows_fetched
426-
)
427-
)
428-
429-
# Get the next table
430-
next_table = self._create_next_table()
431-
if next_table is None:
432-
logger.info("SeaCloudFetchQueue: No more tables available")
433-
break
434-
435-
self.table = next_table
411+
self.table = self._create_next_table()
436412
self.table_row_index = 0
437-
logger.info(
438-
"SeaCloudFetchQueue: Got next table with {} rows".format(
439-
self.table.num_rows if self.table else 0
440-
)
441-
)
442413

443-
logger.info(
444-
"SeaCloudFetchQueue: Retrieved {} total rows".format(results.num_rows)
445-
)
446414
return results
447415

448416
def _create_next_table(self) -> Union["pyarrow.Table", None]:

0 commit comments

Comments
 (0)