Commit 1f6e482
committed
[OPIK-7315] correct why the no-window floor stays at 1900-01-01
The previous commit reached the right value by the wrong argument. It claimed
DateTime64's lower bound does not narrow with precision and is 1900-01-01 at
every precision. That is false, and the docs say so: at precision 9 the type
represents 1677-09-21 00:12:44 .. 2262-04-11 23:47:16, and a value built from
ticks round-trips to the minimum exactly.
SELECT toUnixTimestamp64Nano(fromUnixTimestamp64Nano(toInt64(-9223372036854775808), 'UTC'))
-- -9223372036854775808, exact
What is actually true is narrower and is about the string path this predicate
uses, not about the type. toDateTime64('<string>', N) cannot express anything
before 1900-01-01: it clamps the DATE and KEEPS the time of day, so the result
is silently LATER than asked.
'1677-09-21 00:12:44' -> 1900-01-01 00:12:44 (12m44s later than the plain floor)
'1899-12-31 23:59:59' -> 1900-01-01 23:59:59 (nearly a day later than asked)
'1800-01-01 00:00:00' -> 1900-01-01 00:00:00
The ceiling has no such problem -- '2262-04-11 23:47:16.854775807' parses to
Int64 max exactly -- so the asymmetry is real and worth stating: upper bound
expressible as a string, lower bound not.
Value unchanged; only the comment. Reaching the true minimum would take
fromUnixTimestamp64Nano() in place of the substituted literal, which this file
shares with the windowed gate where the bound must stay an operator-supplied
datetime. Immaterial regardless: nothing in these columns predates 1900.
Caught by a reviewer citing the documented range against my comment. The comment
was wrong; the code was right.1 parent bf0c235 commit 1f6e482
1 file changed
Lines changed: 8 additions & 4 deletions
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
671 | 675 | | |
672 | 676 | | |
673 | 677 | | |
| |||
0 commit comments