Skip to content

EXTRACT(NANOSECOND) on Duration and Interval counts whole seconds twice #26678

Description

@mbutrovich

Describe the bug

SELECT extract(nanosecond from arrow_cast(1500000000, 'Duration(Nanosecond)')),
       extract(nanosecond from interval '1.5 seconds'),
       extract(microsecond from interval '1.5 seconds');
-- 2500000000, 2500000000, 1500000

Expected behavior

1500000000 for both, consistent with microsecond.

Additional context

seconds_ns returns secs * 1_000_000_000 + subsecs. For Duration and Interval, date_part(Nanosecond) already includes the whole seconds. seconds_as_i32 takes subsecs % 1_000_000_000, and seconds_ns doesn't. This has been there since #20674 (54.0.0). Past i32::MAX nanoseconds the NULL-as-zero branch also drops the fraction, so interval '62.5 seconds' gives 2000000000, the Int32 overflow in #14738.

#26676 fixes EXTRACT(EPOCH) on Duration by computing from the i64 value, and #19807 fixed it on Interval from the interval fields. The same approach fits here.

Part of #26672.

Activity

  1. self-assigned this
    on Oct 23, 2026
  2. added theissue type on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions