Skip to content

Decimal -> Decimal cast wrongly fails for large scale reduction #8579

@scovich

Description

@scovich

Describe the bug

Today, attempting to converting from e.g. Decimal32(9, 3) to Decimal32(9, -7) fails with an "overflow" error. The overflow in question is computing pow(10, 3 - (-7)) which indeed overflows 32-bit int.

But that overflow is an implementation detail -- the result of the conversion is perfectly well-defined: value/10000000000 rounds to zero, for all possible unscaled decimal32 values.

To Reproduce

Try to convert Decimal32(9, 3) to Decimal32(9, -7)

Expected behavior

The cast should succeed and produce a column of all-zeros values.

Additional context

Discovered by code inspection, as part of reviewing #8552

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrowChanges to the arrow cratebug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions