File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
datafusion/physical-optimizer/src Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1407,8 +1407,13 @@ pub fn ensure_distribution(
14071407 // It was removed by `remove_dist_changing_operators`
14081408 // and we need to add it back.
14091409 if fetch. is_some ( ) {
1410- // It's safe to unwrap because `spm` is set only if `fetch` is set.
1411- let plan = spm. unwrap ( ) . with_fetch ( fetch. take ( ) ) . unwrap ( ) ;
1410+ // We can make sure that `plan` has an ordering because
1411+ // `SortPreservingMergeExec` requires ordering to be constructed.
1412+ // If there is no ordering, `SortPreservingMergeExec::new` will panic
1413+ let ordering = plan. output_ordering ( ) . cloned ( ) . unwrap ( ) ;
1414+ let plan = Arc :: new (
1415+ SortPreservingMergeExec :: new ( ordering, plan) . with_fetch ( fetch. take ( ) ) ,
1416+ ) ;
14121417 optimized_distribution_ctx =
14131418 DistributionContext :: new ( plan, data, vec ! [ optimized_distribution_ctx] ) ;
14141419 }
You can’t perform that action at this time.
0 commit comments