ozankabak commented on code in PR #12174:
URL: https://github.com/apache/datafusion/pull/12174#discussion_r1734219197


##########
datafusion/physical-plan/src/sorts/sort.rs:
##########
@@ -775,6 +791,19 @@ impl SortExec {
         sort_exprs: LexOrdering,
         preserve_partitioning: bool,
     ) -> PlanProperties {
+        // Determine execution mode:
+        let input_satisfies_sort_req =
+            input.equivalence_properties().ordering_satisfy_requirement(
+                
PhysicalSortRequirement::from_sort_exprs(sort_exprs.iter()).as_slice(),
+            );
+        let mode = match input.execution_mode() {
+            ExecutionMode::Unbounded if input_satisfies_sort_req => {
+                ExecutionMode::Unbounded
+            }
+            ExecutionMode::Bounded => ExecutionMode::Bounded,
+            _ => ExecutionMode::PipelineBreaking,
+        };

Review Comment:
   ```suggestion
           let sort_satisfied =
               input.equivalence_properties().ordering_satisfy_requirement(
                   
PhysicalSortRequirement::from_sort_exprs(sort_exprs.iter()).as_slice(),
               );
           let mode = match input.execution_mode() {
               ExecutionMode::Unbounded if sort_satisfied => {
                   ExecutionMode::Unbounded
               }
               ExecutionMode::Bounded => ExecutionMode::Bounded,
               _ => ExecutionMode::PipelineBreaking,
           };
   ```



##########
datafusion/physical-plan/src/sorts/sort.rs:
##########
@@ -965,12 +1035,125 @@ mod tests {
     use arrow::compute::SortOptions;
     use arrow::datatypes::*;
     use datafusion_common::cast::as_primitive_array;
+    use datafusion_common::Result;
+    use datafusion_common::{assert_batches_eq, ScalarValue};

Review Comment:
   ```suggestion
       use datafusion_common::{assert_batches_eq, Result, ScalarValue};
   ```



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