xiedeyantu commented on code in PR #21362:
URL: https://github.com/apache/datafusion/pull/21362#discussion_r3058052640


##########
datafusion/common/src/functional_dependencies.rs:
##########
@@ -590,6 +590,46 @@ pub fn get_required_group_by_exprs_indices(
         .collect()
 }
 
+/// Returns indices for the minimal subset of ORDER BY expressions that are
+/// functionally equivalent to the original set of ORDER BY expressions.
+pub fn get_required_sort_exprs_indices(
+    schema: &DFSchema,
+    sort_expr_names: &[String],
+) -> Option<Vec<usize>> {
+    let dependencies = schema.functional_dependencies();
+    let field_names = schema.field_names();
+    let sort_expr_indices = sort_expr_names
+        .iter()
+        .map(|sort_expr_name| {
+            field_names
+                .iter()
+                .position(|field_name| field_name == sort_expr_name)
+        })
+        .collect::<Option<Vec<_>>>()?;

Review Comment:
   it can support simplify `order by deptno, total_sal, abs(deptno)` to `order 
by deptno, abs(deptno)` now.



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