You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RecordBatchPartitionSplitter::split returns partitions in hash order #3753
RecordBatchPartitionSplitter::split groups rows in a HashMap, so the (PartitionKey, RecordBatch) pieces come back in hash order, not in the order the partition values appear in the batch.
That breaks ClusteredWriter when its input is already sorted by partition. If a partition spans two batches, the splitter can hand back a later partition first, which closes the earlier one, and then the next batch tries to write to it again and fails with "Cannot write to partition that was previously closed".
Came across this through apache/datafusion-iceberg#39.... its fanout-disabled path feeds split straight into ClusteredWriter. There's a stopgap in apache/datafusion-iceberg#81 that sorts the pieces there, but it fits better in the splitter itself.
To Reproduce
Identity partition on an int column, sorted input written through ClusteredWriter in two batches:
batch 1: [1, 1, 2, 2]
batch 2: [2, 3]
When split returns batch 1 as (2), (1), writing 1 closes partition 2, and batch 2's 2 then fails. Which order you get changes from run to run.
Expected behavior
split returns the pieces in the order each partition value first appears in the batch, so sorted input stays sorted for the clustered writer.
Activity