Skip to content

[C++][Compute] Tighten if_else exact dispatch for parameterized value types#79

Draft
zanmato1984 wants to merge 1 commit into
mainfrom
codex/if-else-parameterized-exact-dispatch
Draft

[C++][Compute] Tighten if_else exact dispatch for parameterized value types#79
zanmato1984 wants to merge 1 commit into
mainfrom
codex/if-else-parameterized-exact-dispatch

Conversation

@zanmato1984

Copy link
Copy Markdown
Owner

Summary

  • tighten if_else exact dispatch so the value operands must fully match as DataTypes before an exact kernel can be selected
  • keep DispatchBest responsible for decimal normalization / cast insertion instead of letting broad type_id matches short-circuit that path
  • add targeted dispatch and expression-binding regressions for decimal casts plus exact-dispatch rejects for timestamp timezone, fixed-size binary, nested, and dictionary mismatches

Root cause

if_else registered several exact kernels with signatures that only matched the value operands by type_id (for example decimals, fixed-size binary, nested, dictionary, and timestamp unit matchers). That let exact dispatch succeed for parameterized value types that were not actually type-equal, which could bypass the normalization and cast-insertion logic that lives in DispatchBest and expression binding.

What changed

  • add a shared MatchConstraint for if_else kernels that requires then and else to have the same full DataType during exact dispatch
  • apply that constraint to the registered primitive, binary, fixed-width, and nested if_else kernels so exact dispatch no longer accepts broader parameterized matches
  • add decimal-focused DispatchBest and expression binding tests to confirm the cast path still runs when exact dispatch is rejected

Validation

  • ./build/debug/arrow-compute-scalar-if-else-test --gtest_filter=TestIfElseKernel.IfElseDispatchBest:TestIfElseKernel.IfElseDispatchExact
  • ./build/debug/arrow-compute-expression-test --gtest_filter=Expression.BindWithImplicitCastsForIfElseOnDecimal

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant