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
ORDER BY CAST(ts AS TIME) can return incorrectly ordered results across midnight #25506
Casting a timestamp to TIME discards the date and is not order-preserving across midnight. However, DataFusion can treat this cast as order-preserving and remove a required sort, returning rows that do not satisfy the requested ORDER BY.
To Reproduce
SELECT ts, CAST(ts ASTIME) AS time_of_day
FROM (
SELECT column1 AS ts
FROM (
VALUES
(TIMESTAMP'1970-01-01 23:59:59'),
(TIMESTAMP'1970-01-02 00:00:00'),
(TIMESTAMP'1970-01-02 00:00:01')
)
ORDER BY ts
LIMIT3
)
ORDER BY time_of_day;
Activity
Toby1009 commentedon Sep 19, 2026
take
fix: preserve sorts for non-monotonic temporal casts (apache#25526)