You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EXTRACT(NANOSECOND) on Duration and Interval counts whole seconds twice #26678
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.
Activity