Skip to content

Displaying a Date64 scalar of i64::MIN panics #24892

Description

@edubraqd

Describe the bug

Formatting a ScalarValue::Date64 whose value is i64::MIN panics. The Display impl unwraps chrono::Duration::try_milliseconds(v), which returns None for i64::MIN because that value is outside the range chrono::Duration can represent (datafusion/common/src/scalar/mod.rs, Date64 arm of impl fmt::Display for ScalarValue).

Any code path that prints such a literal hits it, e.g. plan display.

To Reproduce

EXPLAIN SELECT arrow_cast(-9223372036854775808, 'Date64');
thread 'main' panicked at datafusion/common/src/scalar/mod.rs:5661:82:
called `Option::unwrap()` on a `None` value

Also reachable during execution, e.g. a RANGE window frame over a Date64 column that contains i64::MIN:

SELECT count(*) OVER (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)
FROM (VALUES (arrow_cast(9223372036854775807, 'Date64')), (arrow_cast(-9223372036854775808, 'Date64'))) t(x);

Expected behavior

No panic. The neighbouring branch already maps an unrepresentable epoch offset to an empty string (added for apache/arrow-rs#7728); i64::MIN should behave the same way.

Additional context

Found while running a corpus of extreme-value literals against a debug build of datafusion-cli.

Activity

  1. geographybuff commented on Oct 8, 2026

    @geographybuff
    Contributor

    take

  2. added a commit that references this issue on Oct 8, 2026
    54a4bbf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions