Skip to content

GH-55404: [C++] Fix coalesce exact dispatch for mixed dictionary types - #55405

Open
zanmato1984 wants to merge 1 commit into
apache:mainfrom
zanmato1984:codex/coalesce-dictionary-exact-dispatch-upstream
Open

zanmato1984 wants to merge 1 commit into
apache:mainfrom
zanmato1984:codex/coalesce-dictionary-exact-dispatch-upstream

Conversation

@zanmato1984

@zanmato1984 zanmato1984 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

The coalesce dictionary kernel accepts arguments with different index types, value types, or ordered flags during exact dispatch. Expression binding therefore skips dictionary decoding and type promotion, and the bound expression fails with a TypeError at execution.

What changes are included in this PR?

Require full dictionary type equality using AllTypesAreIdentical(). Mixed dictionary arguments follow the existing best-dispatch and cast-insertion path, while identical dictionary types retain dictionary-encoded execution.

Are these changes tested?

Added exact/best-dispatch and expression binding/execution tests covering differences in index types, value types, and ordering, both argument orders, and variadic calls. Same-type inputs with different dictionary contents verify that dictionary-encoded execution is preserved.

Are there any user-facing changes?

Bound coalesce expressions with compatible mixed dictionary inputs now execute successfully, returning decoded values promoted to a common type where needed.

Was AI used for this PR?

AI generated the implementation, tests, and PR description. The author conducted a thorough review with AI assistance.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

…y types

Signed-off-by: Rossi Sun <zanmato1984@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 20:53
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #55404 has been automatically assigned in GitHub to PR creator.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the dictionary-type dispatch change.

No open issues 🎉

What changed in this PR

Fixes GH-55404 by requiring identical dictionary types for exact coalesce dispatch. Mixed dictionary inputs can then use the existing decoding and type-promotion path during expression binding, while identical types retain dictionary-encoded execution.

Changes:

  • Require full dictionary type equality for the dictionary kernel.
  • Add exact- and best-dispatch tests for differing index types, value types, and ordering flags.
  • Add expression binding and execution tests covering reversed arguments, variadic calls, and identical types with different dictionary contents.
File Description
cpp/​src/​arrow/​compute/​kernels/​scalar_if_else.cc Enforces identical dictionary types during exact dispatch.
cpp/​src/​arrow/​compute/​kernels/​scalar_if_else_test.cc Tests exact dispatch rejection and best-dispatch fallback.
cpp/​src/​arrow/​compute/​expression_test.cc Tests cast insertion, execution results, and dictionary-preserving behavior.

Review effort: Balanced

@zanmato1984
zanmato1984 requested a review from pitrou November 4, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants