alamb opened a new issue, #7794:
URL: https://github.com/apache/arrow-datafusion/issues/7794

   ### Describe the bug
   
   While integrating https://github.com/apache/arrow-datafusion/pull/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](https://github.com/apache/arrow-datafusion/blob/92ba6c3cc1a801762bd157f88f997f70b5123084/datafusion/physical-plan/src/sorts/cursor.rs#L55)
 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_


-- 
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]

Reply via email to