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

[GitHub] [arrow-datafusion] viirya opened a new pull request, #6438: Skip casting result array for binary numerical operators result between array and scalar if possible

viirya opened a new pull request, #6438:
URL: https://github.com/apache/arrow-datafusion/pull/6438

   # 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 #.
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   This is a follow up to #6269.
   
   As we try on upgrading to latest DataFusion 25.0.0 internally, just found this issue. In DataFusion, for numerical operators between Dictionary array (lhs) and literal (rhs), the type of rhs literal will be coerced to Scalar::Dictionary. Although the operation is still between array and literal, the result datatype can be aligned with the operation between array and array.
   
   That's why #6269 is proposed to convert the result between array and literal to match the one between array and array.
   
   But in our case, we don't rely on query analysis and optimization of DataFusion but directly go for physical execution, our query doesn't go through the coercion phase. So the operation is between Dictionary array and original literal (without coerced to Scalar::Dictionary). This leads to different result type as Dictionary array. In such case, we don't need to cast the result array. We can skip casting for the result array if its datatype is already same as binary operator's result type.
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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] viirya merged pull request #6438: Skip casting result array for binary numerical operators result between array and scalar if possible

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


-- 
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] viirya commented on pull request #6438: Skip casting result array for binary numerical operators result between array and scalar if possible

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on PR #6438:
URL: https://github.com/apache/arrow-datafusion/pull/6438#issuecomment-1562438070

   cc @alamb 


-- 
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] viirya commented on pull request #6438: Skip casting result array for binary numerical operators result between array and scalar if possible

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on PR #6438:
URL: https://github.com/apache/arrow-datafusion/pull/6438#issuecomment-1563923809

   Thanks @alamb 


-- 
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] viirya commented on pull request #6438: Skip casting result array for binary numerical operators result between array and scalar if possible

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya commented on PR #6438:
URL: https://github.com/apache/arrow-datafusion/pull/6438#issuecomment-1563448413

   > It might be worth a test so this doesn't accidentally get broken on you in the future
   
   Added a unit test just for the function to make sure it won't be broken.
   
   


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