viirya commented on PR #5675:
URL:
https://github.com/apache/arrow-datafusion/pull/5675#issuecomment-1494753757
> the coercion rule changes make sense to me. However, I don't undertand the
need for Expr::PromotePrecision or the new data_type field on Expr. They don't
seem to be related to improving the coercion for decimals
The coercion rule that modifies sides of arithmetic op is not idempotent.
Multiple runs of the rule will change it to incorrect result. So we need
something to prevent the rule on coerced sides. `PromotePrecision` is such a
thing, it's just a wrapper for the purpose.
For the new `data_type` on `BinaryExpr`. The coerced type of decimal
arithmetic op is not the same as the result type of it as you can see. So we
cannot simply take coerced type of left/right sides and use it as result type.
We cannot compute the result type on-the-fly in physical `BinaryExec` because
it depends on original datatypes of sides of the op, but we only have coerced
at the moment. So we need to record the result type so we can get it when
computing the decimal arithmetic result.
--
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]