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:21:46 UTC

[GitHub] [arrow-datafusion] mpurins-coralogix opened a new issue, #5610: Sort on cast expression removes cast

mpurins-coralogix opened a new issue, #5610:
URL: https://github.com/apache/arrow-datafusion/issues/5610

   **Describe the bug**
   I have found that under certain conditions casts are lost when there is a sort on expression with cast, and that could result in incorrect query results (for example if cast would be from string to integer).
   
   **To Reproduce**
   We hit this when building plan with `LogicalPlanBuilder` directly, but following sql will trigger this as well.
   
   Query `SELECT first_name AS first_name FROM (SELECT first_name AS first_name FROM person) ORDER BY CAST(first_name as INT)` gives us 
   ```
   Sort: first_name AS first_name ASC NULLS LAST
     Projection: first_name AS first_name
         Projection: person.first_name AS first_name
               TableScan: person
   ```
   
   **Expected behavior**
   Query above should give us something like 
   ```
   Sort: CAST(first_name AS Int32) ASC NULLS LAST
     Projection: first_name AS first_name
         Projection: person.first_name AS first_name
               TableScan: person
   ```
   
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->
   


-- 
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.apache.org

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


[GitHub] [arrow-datafusion] alamb closed issue #5610: Sort on cast expression removes cast

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #5610: Sort on cast expression removes cast
URL: https://github.com/apache/arrow-datafusion/issues/5610


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