GH-50624: [C++][Compute] Tighten case_when exact dispatch for parameterized types#50625
Open
zanmato1984 wants to merge 1 commit into
Open
GH-50624: [C++][Compute] Tighten case_when exact dispatch for parameterized types#50625zanmato1984 wants to merge 1 commit into
zanmato1984 wants to merge 1 commit into
Conversation
zanmato1984
marked this pull request as ready for review
July 24, 2026 00:52
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens case_when kernel selection so exact dispatch only accepts identical concrete DataTypes for value arguments (including parameterized/nested types), preventing incorrect kernel matches that could previously yield corrupted results.
Changes:
- Renames the exact-dispatch helper to
AllValueTypesMatchConstraint()and generalizes it to enforce identical value argumentDataTypes. - Applies the same exact-match constraint across all
case_whenvalue kernels (primitive, binary, fixed-size binary, decimals, and nested). - Adds regression tests covering exact-dispatch matching/failing for parameterized types and runtime failures for mismatched parameterized value types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cpp/src/arrow/compute/kernels/scalar_if_else.cc | Enforces identical concrete value DataTypes via a shared match constraint for all case_when kernels to prevent unsafe exact dispatch. |
| cpp/src/arrow/compute/kernels/scalar_if_else_test.cc | Adds coverage ensuring parameterized types only exact-match when identical and that mismatched cases fail as expected. |
zanmato1984
force-pushed
the
codex/case-when-parameterized-exact-dispatch
branch
from
July 24, 2026 01:28
ca07100 to
991fb5d
Compare
zanmato1984
force-pushed
the
codex/case-when-parameterized-exact-dispatch
branch
from
July 24, 2026 02:41
991fb5d to
463e5e4
Compare
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
case_whenexact dispatch was too permissive for parameterized value types. When the value arguments were registered by type id only,DispatchExactcould incorrectly accept incompatible concrete types and return successful but corrupted results instead of failing or falling back toDispatchBest.This fixes #50624.
What changes are included in this PR?
AllValueTypesMatchConstraint()to make its intent explicitDataTypesfixed_size_binary,list,fixed_size_list,struct, and dictionary exact-dispatch mismatchesAre these changes tested?
Yes.
This PR extends
TestCaseWhen.DispatchExactand addsTestCaseWhen.ParameterizedValueTypeMismatch. I also ran targetedarrow-compute-scalar-if-else-testcoverage for:TestCaseWhen.DispatchExactTestCaseWhen.DispatchBestTestCaseWhen.ParameterizedValueTypeMismatchAre there any user-facing changes?
Yes.
case_whennow rejects incompatible parameterized value types that previously could be incorrectly exact-dispatched, which could lead to corrupted results.This PR contains a "Critical Fix". It fixes a bug where
case_whencould return successful but corrupted results for incompatible parameterized value types.