Repository navigation
Commit a167995
fix(datetime): floor negative scalar timestamps in date_trunc (apache#25430)
## Which issue does this PR close?
Closes apache#25425.
## Rationale for this change
Scalar `date_trunc` rounds negative subsecond timestamps toward zero,
while array evaluation floors them to the start of the containing unit.
This makes the result depend on whether the same value is evaluated as a
scalar or a column.
## What changes are included in this PR?
Use checked Euclidean truncation for scalar microsecond-to-millisecond
and nanosecond-to-microsecond/millisecond conversions. This matches
array semantics and returns an error when flooring would underflow.
## Are these changes tested?
Yes. Unit tests cover negative timestamps for all three affected
conversions and underflow at the nanosecond lower bound. The full
workspace extended test suite and strict all-target, all-feature Clippy
checks pass.
## Are there any user-facing changes?
Scalar and array `date_trunc` now agree for negative subsecond
timestamps.
---
Note: This PR was developed with AI assistance. All changes have been
reviewed, and I take full responsibility for this contribution.1 parent 656e425 commit a167995
1 file changed
Lines changed: 38 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
833 | 833 | | |
834 | 834 | | |
835 | 835 | | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
836 | 841 | | |
837 | 842 | | |
838 | 843 | | |
| |||
846 | 851 | | |
847 | 852 | | |
848 | 853 | | |
849 | | - | |
| 854 | + | |
850 | 855 | | |
851 | 856 | | |
852 | 857 | | |
853 | 858 | | |
854 | 859 | | |
855 | | - | |
856 | | - | |
| 860 | + | |
| 861 | + | |
857 | 862 | | |
858 | 863 | | |
859 | 864 | | |
| |||
873 | 878 | | |
874 | 879 | | |
875 | 880 | | |
876 | | - | |
| 881 | + | |
877 | 882 | | |
878 | 883 | | |
879 | 884 | | |
| |||
1361 | 1366 | | |
1362 | 1367 | | |
1363 | 1368 | | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
1364 | 1398 | | |
1365 | 1399 | | |
1366 | 1400 | | |
| |||
0 commit comments