Skip to content

[BUG] Iceberg truncate transform does not handle decimal overflow #4016

@res-life

Description

@res-life

Describe the bug

It's a bug in Iceberg, this issue is just for tracking Iceberg bug purpose.

Iceberg behavior:

    // truncate decimal -999999.999 to -1000000.000, without overflow
    BigDecimal in = new BigDecimal("-999999.999");
    BigDecimal out = truncateDecimal(new BigInteger("10"), in);
    System.out.println(in.precision()); // print 9
    System.out.println(out.precision()); // print 10
    System.out.println(in); // print -999999.999
    System.out.println(out); // print -1000000.000

When truncate min value -999999.999 for decimal 32 type, get result value -1000000.000, the result value is type of decimal64.
Decimal 32 supports max precision 9, while Decimal 64 supports max precision 18.
It's obvious that the precision of -1000000.000 is 10, should use decimal 64.

Note: For the integral types, Iceberg just let overflow happen.

Iceberg reports error when write overflow decimails.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions