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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]