Skip to content

fix(arrow-cast): support full Date32 range when parsing extended-year dates#9961

Open
swanandx wants to merge 1 commit into
apache:mainfrom
swanandx:date32-fix
Open

fix(arrow-cast): support full Date32 range when parsing extended-year dates#9961
swanandx wants to merge 1 commit into
apache:mainfrom
swanandx:date32-fix

Conversation

@swanandx
Copy link
Copy Markdown

@swanandx swanandx commented May 11, 2026

Date32Type::parse previously used chrono::NaiveDate, which caps at roughly +-262,143 years and rejected valid ISO 8601 extended-year inputs like +2739877-01-03

As Gregorian repeats in 400-year era (146,097 days), we find the current era and then calculate & validate the date in current era. We recover the absolute day count by adding era * 146,097.

Claude code's help was taken to come up with this.

Which issue does this PR close?

Rationale for this change

Supporting full range of date's allows other dependents like delta-rs to parse data written/managed by other engines like Spark which support full Date32

changing parse_date() signature is also other option but would need changes with Date64 as well.

What changes are included in this PR?

calculating number of days without converting it full extended year to NaiveDate. And tests for it.

Are these changes tested?

added tests and relying on existing tests for verification

Are there any user-facing changes?

Maybe as we parse some data successfully which would have previously been None / error

… dates

`Date32Type::parse` previously used `chrono::NaiveDate`, which
caps at roughly +-262,143 years and rejected valid ISO 8601 extended-year
inputs like `+2739877-01-03`

As Gregorian repeats in 400-year era (146,097 days), we find the current era and then
calculate & validate the date in current era. We recover the absolute
day count by adding era * 146,097.

Signed-off-by: Swanand Mulay <73115739+swanandx@users.noreply.github.com>
@Jefffrey
Copy link
Copy Markdown
Contributor

run benchmark parse_date

@adriangbot
Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4499278883-221-trfgj 6.12.68+ #1 SMP Wed Apr 1 02:23:28 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 date32-fix (3d26894) to 7abb225 (merge-base) diff
BENCH_NAME=parse_date
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench parse_date
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         date32-fix                             main
-----         ----------                             ----
2020-09-08    1.00     12.4±0.04ns        ? ?/sec    1.00     12.4±0.01ns        ? ?/sec
2020-09-8     1.02     11.7±0.04ns        ? ?/sec    1.00     11.5±0.07ns        ? ?/sec
2020-9-08     1.01     11.6±0.05ns        ? ?/sec    1.00     11.4±0.03ns        ? ?/sec
2020-9-8      1.00     11.0±0.14ns        ? ?/sec    1.05     11.6±0.40ns        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 40.0s
Peak memory 2.7 GiB
Avg memory 2.7 GiB
CPU user 34.1s
CPU sys 0.7s
Peak spill 0 B

branch

Metric Value
Wall time 40.0s
Peak memory 2.7 GiB
Avg memory 2.7 GiB
CPU user 36.6s
CPU sys 0.1s
Peak spill 0 B

File an issue against this benchmark runner

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.

Date32 doesn't parse date with large year

3 participants