Skip to content

panic: to_timestamp overflows converting large Decimal128 to nanoseconds #22213

@Dandandan

Description

@Dandandan

Describe the bug

to_timestamp can panic during planning/constant folding for large Decimal128 values. The decimal-to-nanoseconds conversion multiplies by a power of ten without checking for overflow.

To Reproduce

EXPLAIN SELECT to_timestamp(
  arrow_cast('99999999999999999999999999999999999999', 'Decimal128(38,0)')
);

Actual behavior

thread 'main' panicked at datafusion/functions/src/datetime/to_timestamp.rs:338:9:
attempt to multiply with overflow

Expected behavior

Return an overflow error instead of panicking.

Notes

The panic is in decimal_to_nanoseconds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions