Fokko commented on code in PR #4449:
URL: https://github.com/apache/iceberg-python/pull/4449#discussion_r4697007895


##########
pyiceberg/io/pyarrow.py:
##########
@@ -3315,31 +3318,82 @@ def _dataframe_to_data_files(
         return
 
     if table_metadata.spec().is_unpartitioned():
+        sorted_df, sort_order_id = _sort_table_for_write(table_metadata, df)
         yield from write_file(

Review Comment:
   LGTM, nice one @Anurag-S1ngh :) Streamed back to a generator so partitions 
are not all held in memory at once:
   
   ```suggestion
           def _tasks() -> Iterator[WriteTask]:
               for partition in partitions:
                   sorted_partition, sort_order_id = 
_sort_table_for_write(table_metadata, partition.arrow_table_partition)
                   for batches in bin_pack_arrow_table(sorted_partition, 
target_file_size):
                       yield WriteTask(
                           write_uuid=write_uuid,
                           task_id=next(counter),
                           record_batches=batches,
                           partition_key=partition.partition_key,
                           schema=task_schema,
                           sort_order_id=sort_order_id,
                       )
   
           yield from write_file(io=io, table_metadata=table_metadata, 
tasks=_tasks())
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to