Skip to content

[C++][Compute] coalesce expression binding skips decimal normalization for mixed decimal types #50869

Description

@zanmato1984

Describe the bug, including details regarding any error messages, version, and platform.

On current main (e611f48081), expression binding can incorrectly treat mixed decimal arguments to coalesce as an exact kernel match. This bypasses the decimal normalization in CoalesceFunction::DispatchBest and leaves the bound expression without the required cast to a common decimal type.

For a schema containing:

left:  decimal128(3, 2)
right: decimal128(4, 3)

binding:

call("coalesce", {field_ref("left"), field_ref("right")})

currently produces:

coalesce(left, right)

instead of:

coalesce(cast(left, decimal128(4, 3)), right)

With left = [1.23, null] and right = [null, 2.345], executing the incorrectly bound expression fails with:

Type error: All types must be compatible, expected: decimal128(3, 2), but got: decimal128(4, 3)

The expected result is a decimal128(4, 3) array containing [1.230, 2.345].

Calling DispatchBest directly already normalizes these arguments correctly. The problem is that expression binding tries DispatchExact first, and the broad decimal varargs signature accepts the mixed concrete decimal types before DispatchBest can insert the cast.

This appears to be another instance of the exact-dispatch constraint problem addressed more generally by #47287 and the MatchConstraint mechanism introduced in #47297.

Component(s)

C++

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions