Uh oh!
There was an error while loading. Please reload this page.
GH-41336: [C++][Compute] Fix case_when kernel dispatch for decimals with different precisions and scales - #47479
Conversation
zanmato1984
commented
Sep 3, 2025
| ARROW_EXPORT std::shared_ptr<MatchConstraint> MakeConstraint( | ||
| std::function<bool(const std::vector<TypeHolder>&)> matches); | ||
| /// \brief Convenience function to create a MatchConstraint from a match function. | ||
| static std::shared_ptr<MatchConstraint> Make( |
There was a problem hiding this comment.
Not really related to the issue. Just a small refinement.
| } | ||
| TEST(Expression, BindWithImplicitCastsForCaseWhenOnDecimal) { | ||
| auto exciting_schema = schema( |
| DCHECK(std::all_of(types.begin() + 1, types.end(), [](const TypeHolder& type) { | ||
| return is_decimal(type.id()); | ||
| })); | ||
| const auto& ty1 = checked_cast<const DecimalType&>(*types[1].type); |
There was a problem hiding this comment.
Is the cast actually needed? The Equals method should work as well without it.
There was a problem hiding this comment.
Oh, good catch! I was casting then comparing precisions and scales. Then I found the Equals() method should work and forgot to remove the cast. Updated to use TypeHolder's operator ==. Thanks.
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 8ccdbe7. There weren't enough matching historic benchmark results to make a call on whether there were regressions. The full Conbench report has more details. |
…mals with different precisions and scales (apache#47479) ### Rationale for this change Another case of decimal kernels not able to suppress exact matching when precisions and scales of the arguments differ, causing wrong result type. After apache#47297, we have a systematic way to do that and guide the matching to go to the "best match" (applying implicit casts). ### What changes are included in this PR? Simply added a constraint match that checks if the precisions and scales of the decimal arguments are the same. Also added corresponding tests in forms of both expression (exact match first, then best match) and function call (best match only). ### Are these changes tested? Yes. ### Are there any user-facing changes? None. * GitHub Issue: apache#41336 Authored-by: Rossi Sun <zanmato1984@gmail.com> Signed-off-by: Rossi Sun <zanmato1984@gmail.com>
Rationale for this change
Another case of decimal kernels not able to suppress exact matching when precisions and scales of the arguments differ, causing wrong result type. After #47297, we have a systematic way to do that and guide the matching to go to the "best match" (applying implicit casts).
What changes are included in this PR?
Simply added a constraint match that checks if the precisions and scales of the decimal arguments are the same. Also added corresponding tests in forms of both expression (exact match first, then best match) and function call (best match only).
Are these changes tested?
Yes.
Are there any user-facing changes?
None.