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/16 14:23:38 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5611: Preserve casts in rewrite_sort_cols_by_aggs

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


##########
datafusion/sql/tests/integration_test.rs:
##########
@@ -3252,6 +3252,17 @@ fn test_select_distinct_order_by() {
     assert_eq!(err.to_string(), expected);
 }
 
+#[test]
+fn select_order_by_with_cast() {

Review Comment:
   I verified this test fails without the change in this PR 👍 
   
   ---- select_order_by_with_cast stdout ----
   thread 'select_order_by_with_cast' panicked at 'assertion failed: `(left == right)`
     left: `"Sort: first_name AS first_name ASC NULLS LAST\n  Projection: first_name AS first_name\n    Projection: person.first_name AS first_name\n      TableScan: person"`,
    right: `"Sort: CAST(first_name AS first_name AS Int32) ASC NULLS LAST\n  Projection: first_name AS first_name\n    Projection: person.first_name AS first_name\n      TableScan: person"`', datafusion/sql/tests/integration_test.rs:2433:5
   
   
   



##########
datafusion/expr/src/expr_rewriter/order_by.rs:
##########
@@ -116,7 +116,19 @@ fn rewrite_in_terms_of_projection(
 
         // look for the column named the same as this expr
         if let Some(found) = proj_exprs.iter().find(|a| expr_match(&search_col, a)) {
-            return Ok((*found).clone());
+            let found = found.clone();

Review Comment:
   Yes I agree this is non ideal -- however I can't think of anything better



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