cool9850311 commented on PR #27124: URL: https://github.com/apache/datafusion/pull/27124#issuecomment-6892408860
I'm picking up #27424 (an integer compared with or added to a `Decimal32`/`Decimal64` value casts the decimal to `Int64` and drops its fraction), and it has the same root cause as this PR: the common type of an integer and a decimal has to keep room for the integer's digits. `exact_decimal_type` here is the mechanism #27424 needs, but it runs after `coerce_numeric_type_to_decimal32(other_type)?`, and that helper has no arm for `Int32`/`Int64` because they don't fit `Decimal32`. So `Decimal32(9, 2)` vs `Int64` returns `None` before reaching it and falls back to the integer rules. If the integer side produced a `(precision, scale)` independent of the variant, one rule would cover both: - `Decimal128(38, 38)` vs `Int32` -> `Decimal256(48, 38)` (this PR) - `Decimal32(9, 2)` vs `Int64` -> `Decimal128(22, 2)` (#27424) @jayzhan211 @namanjain24-sudo which would you prefer? 1. #27424 stays separate and only widens where the helper returns `None` — two similar mechanisms in the same function, and both PRs touch the same lines. 2. This PR lands first and I rebase #27424 on top, dropping the `?`. 3. One PR with the general rule, closing both issues. Fine with any of them; I mainly don't want to duplicate work that is already in review 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
