You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/03/15 15:44:25 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5607: [FOLLOWUP] eliminate the duplicated sort keys in Order By clause

alamb commented on code in PR #5607:
URL: https://github.com/apache/arrow-datafusion/pull/5607#discussion_r1137331638


##########
datafusion/optimizer/src/eliminate_duplicated_expr.rs:
##########
@@ -41,15 +42,28 @@ impl OptimizerRule for EliminateDuplicatedExpr {
     ) -> Result<Option<LogicalPlan>> {
         match plan {
             LogicalPlan::Sort(sort) => {
+                let normalized_sort_keys = sort
+                    .expr
+                    .iter()
+                    .map(|e| match e {
+                        Expr::Sort(ExprSort { expr, .. }) => {
+                            Expr::Sort(ExprSort::new(expr.clone(), true, false))

Review Comment:
   I am not sure about always using `true`, `fase`
   
   Using the example
   ```sql
   select * from t1 order by id desc, id, name, id asc;
   select * from t1 order by id asc, id, name, id desc;
   ```
   
   Is the sort key always the same ? It seems like in the first query the sort key should be `id desc, name` and the second it should be `id asc, name`
   
   Maybe I am missing something



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org