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


##########
datafusion/physical-expr-common/src/sort_expr.rs:
##########
@@ -129,23 +138,55 @@ impl PhysicalSortExpr {
             to_str(&self.options)
         )
     }
-}
 
-/// Access the PhysicalSortExpr as a PhysicalExpr
-impl AsRef<dyn PhysicalExpr> for PhysicalSortExpr {
-    fn as_ref(&self) -> &(dyn PhysicalExpr + 'static) {
-        self.expr.as_ref()
+    /// Evaluates the sort expression into a `SortColumn` that can be passed
+    /// into the arrow sort kernel.
+    pub fn evaluate_to_sort_column(&self, batch: &RecordBatch) -> 
Result<SortColumn> {
+        let array_to_sort = match self.expr.evaluate(batch)? {
+            ColumnarValue::Array(array) => array,
+            ColumnarValue::Scalar(scalar) => 
scalar.to_array_of_size(batch.num_rows())?,
+        };
+        Ok(SortColumn {
+            values: array_to_sort,
+            options: Some(self.options),
+        })
+    }
+
+    /// Checks whether this sort expression satisfies the given `requirement`.

Review Comment:
   Agreed, I will add such clarifications.



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