-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Avoid wraparound (timestamp underflow) in toStartOfWeek() #26137
Copy link
Copy link
Closed
Labels
comp-datetimeDate/DateTime/TimeZone datatypes and date-time semantics.Date/DateTime/TimeZone datatypes and date-time semantics.feature
Description
toStartofWeek() does a wraparound (timestamp underflow) in case the timestamp 0 or 1970-01-01 00:00:00
1970-01-01 00:00:00 causes the wraparound since the first day of 1970 is a Thursday.
The result 2106-02-07 does not really make sense.
WITH toDateTime('1970-01-01 00:00:00', 'UTC') AS ts
SELECT toStartOfWeek(ts)
┌─toStartOfWeek(ts)─┐
│ 2106-02-07 │
└───────────────────┘
WITH toDateTime(0, 'UTC') AS ts
SELECT toStartOfWeek(ts)
┌─toStartOfWeek(ts)─┐
│ 2106-02-07 │
└───────────────────┘
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
comp-datetimeDate/DateTime/TimeZone datatypes and date-time semantics.Date/DateTime/TimeZone datatypes and date-time semantics.feature