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
Commit cb0accd
Browse filesBrowse the repository at this point in the historyBrowse files
Extend the supported range of Date32 to [0000-01-01, 9999-12-31]
`Date32` was limited to `[1900-01-01, 2299-12-31]` - the span covered by
the `DateLUTImpl` lookup table - while `DateTime64` was already extended
to `[0000-01-01, 9999-12-31]`. The mismatch was inconsistent on its own:
parsing `toDate32('0079-08-24')` silently clamped to `1900-01-01` (so
e.g. `age` returned a plausible-looking wrong answer), while the cast
`toDate32(toDateTime64('0079-08-24 13:00:00', 0))` produced the correct
out-of-range value, because the `Int32` day number has room for it and
the extended formatting path is shared with `DateTime64`.
`DateLUTImpl::makeDayNum` and `tryToMakeDayNum` now fall back to the
cctz-based `makeDayNumOutOfRange` for valid calendar dates outside
`[DATE_LUT_MIN_YEAR, DATE_LUT_MAX_YEAR]`, exactly like `makeDateTime`
already does since the `DateTime64` extension. That single change covers
text parsing everywhere: SQL casts from `String`, CSV/JSON/TSV/`Values`
input formats, and `YYYYMMDDToDayNum`. Computations over the extended
values were already handled by the `DateTime64` infrastructure, which
gates every `ExtendedDayNum` argument with an out-of-range escape path.
`Date` behavior is unchanged: its clamps happen downstream, on the
day-number result.
The LUT-derived `DATE_LUT_MAX_EXTEND_DAY_NUM` (120530, an exclusive
bound) is replaced by inclusive `DATE_LUT_MIN_EXTEND_DAY_NUM` (-719528,
`0000-01-01`) and `DATE_LUT_MAX_EXTEND_DAY_NUM` (2932896, `9999-12-31`),
tied to the internal representable window by static asserts.
In the numeric conversion `toDate32(N)`, the day-number/timestamp
disambiguation threshold moves accordingly: values up to 2932896 are day
numbers, larger values are Unix timestamps capped at the new
`MAX_DATE32_TIMESTAMP` (`9999-12-31 23:59:59` instead of `2299-12-31
23:59:59`); values below the minimum saturate to `0000-01-01` instead of
`1900-01-01`. The monotonicity analysis threshold is kept in sync, and
the Parquet, Arrow, Arrow IPC and native ORC readers validate `Date32`
input against the new bounds (also fixing an off-by-one that accepted
day number 120530). `makeDate32`, `YYYYMMDDToDate32` and `changeDate`
accept years `[0, 9999]`. The default value of `Date32` and the result
of `toDate32OrZero` on unparseable input remain `1900-01-01`.
Closes#111524
Co-Authored-By: Claude Fable 5 <[email protected]>
Copy file name to clipboardExpand all lines: docs/en/sql-reference/data-types/date32.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ title: 'Date32'
8
8
doc_type: 'reference'
9
9
---
10
10
11
-
A date. Supported range of values: `[1900-01-01, 2299-12-31]`. Stored as a signed 32-bit integer in native byte order with the value representing the days since `1900-01-01`. **Important!** 0 represents `1970-01-01`, and negative values represent the days before `1970-01-01`.
11
+
A date. Supported range of values: `[0000-01-01, 9999-12-31]`. Stored as a signed 32-bit integer in native byte order with the value representing the days since the Unix epoch: 0 represents `1970-01-01`, and negative values represent the days before `1970-01-01`.
A date. Supports the date range from `1900-01-01` to `2299-12-31`. Stored as a signed 32-bit integer in native byte order with the value representing the days since `1900-01-01`. **Important!** 0 represents `1970-01-01`, and negative values represent the days before `1970-01-01`.
29
+
A date. Supports the date range from `0000-01-01` to `9999-12-31`. Stored as a signed 32-bit integer in native byte order with the value representing the days since the Unix epoch: 0 represents `1970-01-01`, and negative values represent the days before `1970-01-01`.
0 commit comments