Skip to content

fix(arrow-cast): check for overflow when converting Date32 -> Timestamp - #9825

Merged
alamb merged 4 commits into
apache:mainfrom
bboissin:push-vkksrnqyuull
Jun 18, 2026
Merged

fix(arrow-cast): check for overflow when converting Date32 -> Timestamp#9825
alamb merged 4 commits into
apache:mainfrom
bboissin:push-vkksrnqyuull

Conversation

@bboissin

Copy link
Copy Markdown
Contributor

Instead of panic (in debug) or wrapping, check for overflow similarly to other conversions (e.g. Timestamp -> Timestamp).

Which issue does this PR close?

Instead of panic (in debug) or wrapping, check for overflow similarly to other
conversions (e.g. Timestamp -> Timestamp).
@github-actions github-actions Bot added the arrow Changes to the arrow crate label Apr 25, 2026
@alamb

alamb commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

run benchmark cast_kernels

@bboissin bboissin changed the title fix(arrow-cast): check for overflow when converting Timestamp -> Date32 fix(arrow-cast): check for overflow when converting Date32 -> Timestamp Apr 28, 2026
@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4338397729-1873-nmthv 6.12.55+ #1 SMP Sun Feb 1 08:59:41 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing push-vkksrnqyuull (881dd3e) to e99815a (merge-base) diff
BENCH_NAME=cast_kernels
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench cast_kernels
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                                              main                                   push-vkksrnqyuull
-----                                                              ----                                   -----------------
"cast decimal128 to float32"                                       1.00     27.3±0.02µs        ? ?/sec    1.00     27.4±0.01µs        ? ?/sec
"cast decimal128 to float64"                                       1.00     27.1±0.01µs        ? ?/sec    1.00     27.1±0.04µs        ? ?/sec
"cast decimal128 to int16"                                         1.01     53.7±2.37µs        ? ?/sec    1.00     53.0±0.59µs        ? ?/sec
"cast decimal128 to int32"                                         1.00     37.5±0.09µs        ? ?/sec    1.01     38.0±0.09µs        ? ?/sec
"cast decimal128 to int64"                                         1.01     36.8±0.37µs        ? ?/sec    1.00     36.4±0.09µs        ? ?/sec
"cast decimal128 to int8"                                          1.00     51.4±0.70µs        ? ?/sec    1.00     51.5±0.65µs        ? ?/sec
"cast decimal128 to uint16"                                        1.01     54.9±1.89µs        ? ?/sec    1.00     54.4±0.73µs        ? ?/sec
"cast decimal128 to uint32"                                        1.00     36.1±0.08µs        ? ?/sec    1.00     36.0±0.08µs        ? ?/sec
"cast decimal128 to uint64"                                        1.00     35.2±0.06µs        ? ?/sec    1.00     35.3±0.10µs        ? ?/sec
"cast decimal128 to uint8"                                         1.00     49.9±0.46µs        ? ?/sec    1.00     49.9±0.48µs        ? ?/sec
"cast decimal256 to float32"                                       1.00     70.4±0.02µs        ? ?/sec    1.00     70.5±0.04µs        ? ?/sec
"cast decimal256 to float64"                                       1.00     68.3±0.05µs        ? ?/sec    1.00     68.4±0.09µs        ? ?/sec
"cast decimal256 to int16"                                         1.00    165.8±1.13µs        ? ?/sec    1.01    167.2±0.74µs        ? ?/sec
"cast decimal256 to int32"                                         1.00    144.4±0.18µs        ? ?/sec    1.01    146.2±0.17µs        ? ?/sec
"cast decimal256 to int64"                                         1.00    142.2±0.76µs        ? ?/sec    1.00    142.5±0.83µs        ? ?/sec
"cast decimal256 to int8"                                          1.00    161.8±0.95µs        ? ?/sec    1.00    162.4±0.93µs        ? ?/sec
"cast decimal256 to uint16"                                        1.00    166.5±0.71µs        ? ?/sec    1.00    166.6±0.49µs        ? ?/sec
"cast decimal256 to uint32"                                        1.00    132.3±0.39µs        ? ?/sec    1.05    138.3±0.55µs        ? ?/sec
"cast decimal256 to uint64"                                        1.00    132.6±0.46µs        ? ?/sec    1.01    133.5±0.45µs        ? ?/sec
"cast decimal256 to uint8"                                         1.00    163.3±0.50µs        ? ?/sec    1.00    163.9±0.46µs        ? ?/sec
"cast decimal32 to float32"                                        1.00      6.8±0.00µs        ? ?/sec    1.00      6.8±0.00µs        ? ?/sec
"cast decimal32 to float64"                                        1.00      6.8±0.01µs        ? ?/sec    1.00      6.8±0.00µs        ? ?/sec
"cast decimal32 to int16"                                          1.03     26.4±0.43µs        ? ?/sec    1.00     25.7±0.25µs        ? ?/sec
"cast decimal32 to int32"                                          1.00     20.1±0.14µs        ? ?/sec    1.02     20.4±0.19µs        ? ?/sec
"cast decimal32 to int64"                                          1.00     20.2±0.18µs        ? ?/sec    1.00     20.2±0.24µs        ? ?/sec
"cast decimal32 to int8"                                           1.00     33.0±0.58µs        ? ?/sec    1.01     33.3±0.56µs        ? ?/sec
"cast decimal32 to uint16"                                         1.00     26.0±0.39µs        ? ?/sec    1.01     26.2±0.49µs        ? ?/sec
"cast decimal32 to uint32"                                         1.02     20.6±0.21µs        ? ?/sec    1.00     20.1±0.21µs        ? ?/sec
"cast decimal32 to uint64"                                         1.00     20.2±0.21µs        ? ?/sec    1.01     20.5±0.23µs        ? ?/sec
"cast decimal32 to uint8"                                          1.00     33.0±0.50µs        ? ?/sec    1.01     33.3±0.41µs        ? ?/sec
"cast decimal64 to float32"                                        1.00      6.8±0.00µs        ? ?/sec    1.00      6.8±0.00µs        ? ?/sec
"cast decimal64 to float64"                                        1.00      6.8±0.00µs        ? ?/sec    1.00      6.8±0.00µs        ? ?/sec
"cast decimal64 to int16"                                          1.05     35.9±4.60µs        ? ?/sec    1.00     34.0±0.31µs        ? ?/sec
"cast decimal64 to int32"                                          1.00     26.3±0.08µs        ? ?/sec    1.00     26.3±0.09µs        ? ?/sec
"cast decimal64 to int64"                                          1.00     26.5±0.08µs        ? ?/sec    1.00     26.5±0.09µs        ? ?/sec
"cast decimal64 to int8"                                           1.00     34.1±0.23µs        ? ?/sec    1.00     34.1±0.30µs        ? ?/sec
"cast decimal64 to uint16"                                         1.06     36.0±4.68µs        ? ?/sec    1.00     34.1±0.36µs        ? ?/sec
"cast decimal64 to uint32"                                         1.00     26.1±0.13µs        ? ?/sec    1.00     26.0±0.08µs        ? ?/sec
"cast decimal64 to uint64"                                         1.00     26.0±0.15µs        ? ?/sec    1.00     26.0±0.07µs        ? ?/sec
"cast decimal64 to uint8"                                          1.00     34.0±0.22µs        ? ?/sec    1.00     33.9±0.32µs        ? ?/sec
"cast float32 to decimal128(32, 3)"                                1.00     33.7±0.30µs        ? ?/sec    1.01     33.9±0.36µs        ? ?/sec
"cast float32 to decimal256(76, 4)"                                1.01    512.5±6.76µs        ? ?/sec    1.00    508.9±6.99µs        ? ?/sec
"cast float32 to decimal32(9, 2)"                                  1.00     20.5±0.89µs        ? ?/sec    1.01     20.7±0.95µs        ? ?/sec
"cast float32 to decimal64(18, 2"                                  1.00     21.2±0.66µs        ? ?/sec    1.02     21.6±0.78µs        ? ?/sec
"cast float64 to decimal128(32, 3)"                                1.00     32.0±0.52µs        ? ?/sec    1.00     32.1±0.45µs        ? ?/sec
"cast float64 to decimal256(76, 4)"                                1.01    510.4±7.51µs        ? ?/sec    1.00    504.1±7.09µs        ? ?/sec
"cast float64 to decimal32(9, 2)"                                  1.03     21.6±1.12µs        ? ?/sec    1.00     21.0±1.09µs        ? ?/sec
"cast float64 to decimal64(18, 2"                                  1.00     21.4±0.64µs        ? ?/sec    1.00     21.5±0.76µs        ? ?/sec
"cast invalid float32 to decimal128(32, 3)"                        1.07     23.2±1.01µs        ? ?/sec    1.00     21.6±0.70µs        ? ?/sec
"cast invalid float32 to decimal256(76, 4)"                        1.01     40.6±0.58µs        ? ?/sec    1.00     40.4±0.70µs        ? ?/sec
"cast invalid float32 to decimal32(9, 2)"                          1.00     22.9±1.85µs        ? ?/sec    1.02     23.3±1.87µs        ? ?/sec
"cast invalid float32 to decimal64(18, 2"                          1.00     21.8±1.24µs        ? ?/sec    1.08     23.6±2.24µs        ? ?/sec
"cast invalid float64 to decimal32(9, 2)"                          1.00     20.5±1.15µs        ? ?/sec    1.11     22.8±1.89µs        ? ?/sec
"cast invalid float64 to to decimal128(32, 3)"                     1.01     22.4±1.01µs        ? ?/sec    1.00     22.3±1.37µs        ? ?/sec
"cast invalid float64 to to decimal256(76, 4)"                     1.00     39.2±0.68µs        ? ?/sec    1.01     39.6±0.97µs        ? ?/sec
"cast invalid float64 to to decimal64(18, 2)"                      1.07     22.5±1.07µs        ? ?/sec    1.00     20.9±1.96µs        ? ?/sec
"cast invalid string to decimal128(38, 3)"                         1.00    711.0±1.00µs        ? ?/sec    1.00    713.6±1.12µs        ? ?/sec
"cast invalid string to decimal256(76, 4)"                         1.00    714.2±0.55µs        ? ?/sec    1.00    712.0±0.43µs        ? ?/sec
"cast invalid string to decimal32(9, 2)"                           1.00    684.8±0.78µs        ? ?/sec    1.00    683.7±0.74µs        ? ?/sec
"cast invalid string to decimal64(18, 2)"                          1.00    686.5±1.32µs        ? ?/sec    1.00    685.3±0.69µs        ? ?/sec
"cast string to decimal128(38, 3)"                                 1.00    640.3±0.63µs        ? ?/sec    1.02    651.3±1.18µs        ? ?/sec
"cast string to decimal256(76, 4)"                                 1.00    656.8±0.77µs        ? ?/sec    1.01    662.7±0.59µs        ? ?/sec
"cast string to decimal32(9, 2)"                                   1.00    789.2±0.53µs        ? ?/sec    1.00    789.0±1.60µs        ? ?/sec
"cast string to decimal64(18, 2)"                                  1.00    621.4±0.39µs        ? ?/sec    1.02    634.4±1.56µs        ? ?/sec
cast binary view to string                                         1.00     58.3±0.45µs        ? ?/sec    1.01     58.6±0.52µs        ? ?/sec
cast binary view to string view                                    1.00     63.7±0.32µs        ? ?/sec    1.02     65.1±0.19µs        ? ?/sec
cast binary view to wide string                                    1.01     58.7±0.52µs        ? ?/sec    1.00     58.3±0.45µs        ? ?/sec
cast date32 to date64 512                                          1.00    322.7±0.85ns        ? ?/sec    1.02    329.5±0.31ns        ? ?/sec
cast date64 to date32 512                                          1.00    401.4±0.38ns        ? ?/sec    1.03    412.8±0.58ns        ? ?/sec
cast decimal128 to decimal128 512                                  1.00      6.9±0.00µs        ? ?/sec    1.00      6.9±0.01µs        ? ?/sec
cast decimal128 to decimal128 512 lower precision                  1.00     13.6±0.03µs        ? ?/sec    1.00     13.6±0.05µs        ? ?/sec
cast decimal128 to decimal128 512 with lower scale (infallible)    1.00     45.9±0.05µs        ? ?/sec    1.00     45.9±0.05µs        ? ?/sec
cast decimal128 to decimal128 512 with same scale                  1.00     76.8±0.40ns        ? ?/sec    1.01     77.2±0.57ns        ? ?/sec
cast decimal128 to decimal256 512                                  1.00     26.3±0.01µs        ? ?/sec    1.00     26.2±0.02µs        ? ?/sec
cast decimal256 to decimal128 512                                  1.00    310.1±0.22µs        ? ?/sec    1.02    314.8±0.32µs        ? ?/sec
cast decimal256 to decimal256 512                                  1.00     82.0±0.06µs        ? ?/sec    1.00     82.1±0.13µs        ? ?/sec
cast decimal256 to decimal256 512 with same scale                  1.00     77.2±1.06ns        ? ?/sec    1.01     77.7±0.63ns        ? ?/sec
cast decimal32 to decimal32 512                                    1.00      8.6±0.01µs        ? ?/sec    1.01      8.7±0.01µs        ? ?/sec
cast decimal32 to decimal32 512 lower precision                    1.00      9.9±0.05µs        ? ?/sec    1.01     10.1±0.05µs        ? ?/sec
cast decimal32 to decimal64 512                                    1.00      3.4±0.05µs        ? ?/sec    1.00      3.4±0.00µs        ? ?/sec
cast decimal64 to decimal32 512                                    1.00     32.4±0.01µs        ? ?/sec    1.00     32.4±0.02µs        ? ?/sec
cast decimal64 to decimal64 512                                    1.00      2.8±0.00µs        ? ?/sec    1.00      2.9±0.00µs        ? ?/sec
cast dict to string view                                           1.00     40.6±1.51µs        ? ?/sec    1.01     41.1±1.55µs        ? ?/sec
cast f32 to string 512                                             1.01     11.6±0.06µs        ? ?/sec    1.00     11.5±0.03µs        ? ?/sec
cast f64 to string 512                                             1.00     15.3±0.07µs        ? ?/sec    1.00     15.2±0.04µs        ? ?/sec
cast float32 to int32 512                                          1.00   1374.2±4.25ns        ? ?/sec    1.01   1389.6±4.64ns        ? ?/sec
cast float64 to float32 512                                        1.00    681.9±5.16ns        ? ?/sec    1.01    685.8±1.62ns        ? ?/sec
cast float64 to uint64 512                                         1.04  1457.8±12.73ns        ? ?/sec    1.00  1398.9±13.61ns        ? ?/sec
cast i64 to string 512                                             1.00      8.8±0.06µs        ? ?/sec    1.00      8.9±0.03µs        ? ?/sec
cast int32 to float32 512                                          1.00    699.9±5.53ns        ? ?/sec    1.01    709.3±4.27ns        ? ?/sec
cast int32 to float64 512                                          1.02    723.2±2.34ns        ? ?/sec    1.00    711.8±2.69ns        ? ?/sec
cast int32 to int32 512                                            1.00    172.4±0.91ns        ? ?/sec    1.03    177.0±4.38ns        ? ?/sec
cast int32 to int64 512                                            1.00    696.4±2.71ns        ? ?/sec    1.02    713.3±3.13ns        ? ?/sec
cast int32 to uint32 512                                           1.00   1380.0±5.62ns        ? ?/sec    1.01  1396.2±16.57ns        ? ?/sec
cast int64 to int32 512                                            1.00   1482.1±1.81ns        ? ?/sec    1.02  1510.0±22.89ns        ? ?/sec
cast no runs of int32s to ree<int32>                               1.00     56.9±0.77µs        ? ?/sec    1.03     58.6±1.77µs        ? ?/sec
cast runs of 10 string to ree<int32>                               1.00      8.8±0.05µs        ? ?/sec    1.00      8.8±0.06µs        ? ?/sec
cast runs of 1000 int32s to ree<int32>                             1.01      3.4±0.01µs        ? ?/sec    1.00      3.4±0.01µs        ? ?/sec
cast string single run to ree<int32>                               1.00     27.3±0.01µs        ? ?/sec    1.01     27.5±0.01µs        ? ?/sec
cast string to binary view 512                                     1.00      2.3±0.02µs        ? ?/sec    1.00      2.3±0.02µs        ? ?/sec
cast string view to binary view                                    1.00     74.2±1.31ns        ? ?/sec    1.05     77.6±5.41ns        ? ?/sec
cast string view to dict                                           1.00    174.8±0.68µs        ? ?/sec    1.00    174.8±0.71µs        ? ?/sec
cast string view to string                                         1.00     44.7±2.25µs        ? ?/sec    1.03     45.9±2.23µs        ? ?/sec
cast string view to wide string                                    1.00     46.5±2.03µs        ? ?/sec    1.00     46.4±1.72µs        ? ?/sec
cast time32s to time32ms 512                                       1.00    138.8±0.28ns        ? ?/sec    1.08    150.2±0.40ns        ? ?/sec
cast time32s to time64us 512                                       1.00    322.9±0.95ns        ? ?/sec    1.02    329.6±0.35ns        ? ?/sec
cast time64ns to time32s 512                                       1.00    402.5±0.35ns        ? ?/sec    1.03    412.5±0.45ns        ? ?/sec
cast timestamp_ms to i64 512                                       1.03    257.6±4.76ns        ? ?/sec    1.00    251.3±1.46ns        ? ?/sec
cast timestamp_ms to timestamp_ns 512                              1.00   1837.4±4.17ns        ? ?/sec    1.02   1881.6±3.77ns        ? ?/sec
cast timestamp_ns to timestamp_s 512                               1.00    171.8±1.34ns        ? ?/sec    1.02    175.7±3.61ns        ? ?/sec
cast utf8 to date32 512                                            1.01      6.5±0.04µs        ? ?/sec    1.00      6.4±0.03µs        ? ?/sec
cast utf8 to date64 512                                            1.00     32.0±0.08µs        ? ?/sec    1.00     32.0±0.09µs        ? ?/sec
cast utf8 to f32                                                   1.00      5.6±0.03µs        ? ?/sec    1.02      5.7±0.03µs        ? ?/sec
cast wide string to binary view 512                                1.00      4.1±0.07µs        ? ?/sec    1.00      4.1±0.08µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 1150.2s
Peak memory 3.0 GiB
Avg memory 3.0 GiB
CPU user 1144.3s
CPU sys 0.8s
Peak spill 0 B

branch

Metric Value
Wall time 1135.3s
Peak memory 3.0 GiB
Avg memory 3.0 GiB
CPU user 1132.4s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some simplification suggestions

Comment thread arrow-cast/src/cast/mod.rs Outdated
Comment thread arrow-cast/src/cast/mod.rs Outdated
pull Bot pushed a commit to TCeason/arrow-datafusion that referenced this pull request Jun 14, 2026
## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->

- Closes apache#22896.

## Rationale for this change

`TRY_CAST` should return NULL on cast failure, but overflowing
date/timestamp casts returned errors.

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->

## What changes are included in this PR?
  
- Make scalar temporal overflow checks respect CastOptions.safe.
- Skip DataFusion’s array pre-check for safe casts so Arrow can return
NULLs.
- Add regression tests.

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

## Are these changes tested?

Yes:

```bash
cargo test -p datafusion-common timestamp_overflow_returns
cargo test -p datafusion-expr-common timestamp_array_to_timestamp_overflow
cargo test --test sqllogictests -- datetime/timestamps.slt
```

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

## Are there any user-facing changes?

Yes. TRY_CAST for overflowing date/timestamp casts now returns NULL;
regular CAST still errors.

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->

## Known Limitation

This PR does not add Date array-path coverage yet. For example:

```sql
SELECT TRY_CAST(d AS TIMESTAMP(9))
FROM (VALUES (DATE '3000-01-01')) t(d);
```

This depends on the upstream Arrow fix in apache/arrow-rs#9825. Once
DataFusion updates to an Arrow version containing that fix, we can add
this regression test.
@alamb
alamb merged commit b220251 into apache:main Jun 18, 2026
30 checks passed
@alamb

alamb commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Thank you @bboissin and @Jefffrey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cast: overflow when converting Date32 -> Timestamp

4 participants