-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the bug
While integrating #7671 and turning on with_bounded_order_preserving_variants (since renamed to prefer_existing_sort) in IOx, some of our plans end up with a SortPreservingRepartitionExec that had no sort expressions
This caused a very non intuitive error much later in the plan -- interleave paniced with Panic: range end index 8192 out of range for slice of length 1
To Reproduce
I tracked down the proximate cause of the problem which was that a RowCursor with a batch of 1 row but the converted Rows has num_rows = 0 was created and then call to is_finished never returns true: https://github.com/apache/arrow-datafusion/blob/92ba6c3cc1a801762bd157f88f997f70b5123084/datafusion/physical-plan/src/sorts/cursor.rs#L107 (because advance is always called first)
The plan in question looks like this:
| problem --> SortPreservingRepartitionExec: partitioning=Hash([iox::measurement@0], 16), input_partitions=16 <-- this has no sport expressions
| RepartitionExec: partitioning=RoundRobinBatch(16), input_partitions=2
| UnionExec
| ProjectionExec: expr=[cpu as iox::measurement, 0 as time, AVG(cpu.usage_idle)@0 as mean, NULL as mean_1]
| AggregateExec: mode=Final, gby=[], aggr=[AVG(cpu.usage_idle)]
| CoalescePartitionsExec
|
I am still working out a smaller reproducer for this issue, but filing the ticket for more visibility.
Expected behavior
No response
Additional context
No response