Skip to content

[VL] Incorrect result type of nested decimal arithmetic expressions #7082

@jiangjiangtian

Description

@jiangjiangtian

Backend

VL (Velox)

Bug description

The SQL as follows will produce wrong result:

select col0 / (col1 + 0.00001) from table;

where col0 and col1 is decimal(20, 0).
The values of col0 and col1 are 25 and 72. Gluten returns 3.4722217399692027821 and spark returns 0.3472221739969202782.
The result type needs to be decimal(38, 19). But during calculation, the actual result type is decimal(38, 20):
image
The reason is that the type of the subexpression col1 + 0.00001 will be rescaled to decimal(27, 5):
截屏2024-09-02 17 15 29
But we don't notice it when we rescale the topmost expression:
截屏2024-09-02 17 16 06

Spark version

None

Spark configurations

No response

System information

No response

Relevant logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions