Skip to content

[C++] Decimal types array compare with different scales make error results #41011

Description

@ZhangHuiGui

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

Our CompareFunction has it's own DispatchBest and supposed do cast with kAdd promotion rule during Bind.

Result<const Kernel*> DispatchBest(std::vector<TypeHolder>* types) constoverride {
RETURN_NOT_OK(CheckArity(types->size()));
if (HasDecimal(*types)) {
RETURN_NOT_OK(CastBinaryDecimalArgs(DecimalPromotion::kAdd, types));
}

But we haven't check the input decimal types' scale as ResolveDecimalAdditionOrSubtractionOutput does.

for (constauto id : {Type::DECIMAL128, Type::DECIMAL256}) {
auto exec = GenerateDecimal<applicator::ScalarBinaryEqualTypes, BooleanType, Op>(id);
DCHECK_OK(
func->AddKernel({InputType(id), InputType(id)}, boolean(), std::move(exec)));
}

So the decimal array's comparison won't be casted and it's results will wrong when input decimal's scales are same.

Component(s)

C++

Activity

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions