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

[GitHub] [arrow-datafusion] mpurins-coralogix opened a new pull request, #5611: Preserve casts in rewrite_sort_cols_by_aggs

mpurins-coralogix opened a new pull request, #5611:
URL: https://github.com/apache/arrow-datafusion/pull/5611

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #5610.
   
   # Rationale for this change
   
   I changed `rewrite_in_terms_of_projection` to add casts back, but I honestly have no idea if this is proper way to fix this but it does the trick and would appreciate some direction.
   
   # What changes are included in this PR?
   
   # Are these changes tested?
   
   Added two new tests.
   
   # Are there any user-facing changes?
   
   Bugfix.


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


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

Posted by "mpurins-coralogix (via GitHub)" <gi...@apache.org>.
mpurins-coralogix commented on code in PR #5611:
URL: https://github.com/apache/arrow-datafusion/pull/5611#discussion_r1136829589


##########
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)) {

Review Comment:
   `into_iter` would consume `proj_exprs` which can not be done here because it is captured in closure which is passed to `rewrite_expr`



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


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

Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan commented on code in PR #5611:
URL: https://github.com/apache/arrow-datafusion/pull/5611#discussion_r1137010469


##########
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:
   The fragile here to me seems to be that the code assumes some naming, and with casting it removes the cast expression. Ideally we wouldn't depend on the naming in the code but on the expressions themselves.



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


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

Posted by "alamb (via GitHub)" <gi...@apache.org>.
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


[GitHub] [arrow-datafusion] alamb merged pull request #5611: Preserve casts in rewrite_sort_cols_by_aggs

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #5611:
URL: https://github.com/apache/arrow-datafusion/pull/5611


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


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

Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan commented on code in PR #5611:
URL: https://github.com/apache/arrow-datafusion/pull/5611#discussion_r1137006692


##########
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)) {

Review Comment:
    ok : 👌



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


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

Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan commented on code in PR #5611:
URL: https://github.com/apache/arrow-datafusion/pull/5611#discussion_r1136805548


##########
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)) {

Review Comment:
   `into_iter` might prevent the clone later on?



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