Skip to content

[C++][Compute] Inaccurate calculation results will be produced when the 'cases' arrays of 'case_when' have different Decimal types #41336

Description

@ZhangHuiGui

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

It's an interesting problem we find recently in case_when kernel.

For the call function:
CaseWhen({MakeStruct({cond1, cond2, cond3}), {arr1, arr2, arr3, arr4}})
will produce the case_when logic like below:

cond1 --> arr1 decimal(9,7),
cond2 --> arr2 decimal(6,2),
cond3 --> arr3 decimal(3, 2),
arr4 decimal(2,1)

The case_when will use the LastType which is decimal(2,1) as it's output type.

ScalarKernel kernel(
KernelSignature::Make({InputType(Type::STRUCT), InputType(get_id.id)}, LastType,
/*is_varargs=*/true),
.

That means for the arr1/arr2/arr3's output results, the precision will be set to decimal(2,1), obviously it's inaccurate in fact especially when the case_when as an expression combining with aggregate's sum/avg....

laotan332 qinpengxiang@outlook.com

Component(s)

C++

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions