GH-41336: [C++][Compute] Fix case_when kernel dispatch for decimals with different precisions and scales#47479
Merged
zanmato1984 merged 3 commits intoapache:mainfrom Sep 3, 2025
Merged
Conversation
Contributor
Author
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( |
Contributor
Author
There was a problem hiding this comment.
Not really related to the issue. Just a small refinement.
pitrou
reviewed
Sep 3, 2025
| } | ||
|
|
||
| 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); |
Member
There was a problem hiding this comment.
Is the cast actually needed? The Equals method should work as well without it.
Contributor
Author
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.
pitrou
approved these changes
Sep 3, 2025
This was referenced Sep 3, 2025
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.