Skip to content

fix: keep fractional seconds in EXTRACT(EPOCH) for Duration - #26676

Merged
mbutrovich merged 5 commits into
apache:mainfrom
mbutrovich:fix-epoch-duration-fraction
Oct 23, 2026
Merged

mbutrovich merged 5 commits into
apache:mainfrom
mbutrovich:fix-epoch-duration-fraction

Conversation

@mbutrovich

@mbutrovich mbutrovich commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

The old code was complicated because it reused a helper written for timestamps. #12514 sent Duration epochs through seconds and added % 1_000_000_000 and a NULL-as-zero branch to recover the fraction, which works only while the total fits in i32. #19807 fixed the same bug for Interval and left Duration on that path.

What changes are included in this PR?

The Duration arms of epoch now divide the i64 value by the unit's factor with unary, like the Timestamp arms, and seconds is gone. The first commit adds two cases to the datetime_expressions bench without the fix, so the benchmark bot can compare against it.

It is also 2.5x to 12x faster on the benchmark bot. main made three passes over the batch and fell back to a row-by-row iterator on any NULL or large value. The new loop takes the same time whatever the values or NULLs.

epoch-duration-bot
Numbers and codegen

Speedups over 353e4cee5 (the bench commit) on 1000 rows, with the bot's thin LTO. "Nulls" means 10% of rows are NULL. The aligned runs add -align-all-functions=6 -align-all-nofallthru-blocks=6.

Case Neoverse-V2 aligned Xeon 8581C aligned
duration_ns 5.60x 5.57x 8.09x 6.95x
duration_ns_nulls 7.11x 7.31x 12.08x 10.68x
duration_ns_small 2.50x 2.45x 4.50x 3.53x
ns (unchanged) 1.00x 1.01x 1.09x 1.03x

In the default Xeon run the unchanged cases are 1.09x to 1.19x, so that run overstates the gain by about 15%.

Timing each arrow kernel of main's path separately on 8192 rows on an Apple M5 Max accounts for its totals.

Values date_part(Second) date_part(Nanosecond) Combine Sum
Under 2.1 s, binary 2.94 us 2.32 us 2.44 us 7.70 us
Large, iterator collect 2.92 us 12.86 us 16.47 us 32.25 us

LLVM merges the new loops with the existing Timestamp and Time64 ones, so this PR adds no new loop code. On aarch64 the loop handles 8 rows per iteration with scvtf.2d and fdiv.2d. On x86_64 the division is packed (divpd, vdivpd with AVX2) and the i64 to f64 conversion is scalar cvtsi2sd, because the packed form needs AVX-512DQ. I read this with cargo asm (rustc 1.99.0, release-nonlto).

The code divides rather than multiplying by 1e-9. The division is most of the loop's time on Neoverse-V2, where date_part_epoch_s_1000 (no division) takes 412 ns against 1.21 us for ns. The multiply would be faster, but it changes 14% of Duration(ms) and 41% of Duration(ns) results, for example 12.92335 s becomes 12.923350000000001.

What is the testing strategy for this PR?

New cases in datafusion/sqllogictest/test_files/datetime/date_part.slt under test_extract_duration cover the i32::MAX ns boundary, each Duration unit, the issue's reproducer, negative values, NULLs mixed with values, and i64 extremes.

Are there any user-facing changes?

EXTRACT(EPOCH) on Duration returns correct results. There are no public API changes.

AI Disclosure

I wrote this PR with help from Claude but understand and support the core approach, implementation, and test coverage.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Oct 23, 2026
@mbutrovich
mbutrovich force-pushed the fix-epoch-duration-fraction branch from 31bfea9 to e391b4d Compare October 23, 2026 18:54
@mbutrovich

mbutrovich commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

run benchmark datetime_expressions

env:
  BENCH_FILTER: date_part_epoch
baseline:
  ref: 353e4cee59f9172d86d284bdc4e08989e4a05192

@mbutrovich

Copy link
Copy Markdown
Contributor Author

run benchmark datetime_expressions

env:
  BENCH_FILTER: date_part_epoch
baseline:
  ref: 353e4cee59f9172d86d284bdc4e08989e4a05192
resources:
  arch: amd64

@mbutrovich

Copy link
Copy Markdown
Contributor Author

run benchmark datetime_expressions

env:
  BENCH_FILTER: date_part_epoch
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: 353e4cee59f9172d86d284bdc4e08989e4a05192

@mbutrovich

Copy link
Copy Markdown
Contributor Author

run benchmark datetime_expressions

env:
  BENCH_FILTER: date_part_epoch
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: 353e4cee59f9172d86d284bdc4e08989e4a05192
resources:
  arch: amd64

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c6372473305-3802-s26jm 6.12.105+ #1 SMP Sat Sep 5 07:54:11 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 fix-epoch-duration-fraction (e391b4d) to 353e4ce diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_epoch"
baseline:
  ref: "353e4cee59f9172d86d284bdc4e08989e4a05192"

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c6372495185-3805-vlx6h 6.12.105+ #1 SMP Sat Sep 5 07:57:24 UTC 2026 x86_64 GNU/Linux

CPU Details (lscpu)
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           52 bits physical, 57 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               GenuineIntel
Model name:                              INTEL(R) XEON(R) PLATINUM 8581C CPU @ 2.30GHz
CPU family:                              6
Model:                                   207
Thread(s) per core:                      2
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                2
BogoMIPS:                                4600.00
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd arat avx512vbmi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid cldemote movdiri movdir64b fsrm md_clear serialize tsxldtrk amx_bf16 avx512_fp16 amx_tile amx_int8 arch_capabilities
Hypervisor vendor:                       KVM
Virtualization type:                     full
L1d cache:                               384 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                16 MiB (8 instances)
L3 cache:                                260 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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing fix-epoch-duration-fraction (e391b4d) to 353e4ce diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_epoch"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: "353e4cee59f9172d86d284bdc4e08989e4a05192"
resources:
  arch: "amd64"

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c6372487442-3803-xzwzn 6.12.105+ #1 SMP Sat Sep 5 07:57:24 UTC 2026 x86_64 GNU/Linux

CPU Details (lscpu)
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           52 bits physical, 57 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               GenuineIntel
Model name:                              INTEL(R) XEON(R) PLATINUM 8581C CPU @ 2.30GHz
CPU family:                              6
Model:                                   207
Thread(s) per core:                      2
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                2
BogoMIPS:                                4600.00
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd arat avx512vbmi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid cldemote movdiri movdir64b fsrm md_clear serialize tsxldtrk amx_bf16 avx512_fp16 amx_tile amx_int8 arch_capabilities
Hypervisor vendor:                       KVM
Virtualization type:                     full
L1d cache:                               384 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                16 MiB (8 instances)
L3 cache:                                260 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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing fix-epoch-duration-fraction (e391b4d) to 353e4ce diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_epoch"
baseline:
  ref: "353e4cee59f9172d86d284bdc4e08989e4a05192"
resources:
  arch: "amd64"

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c6372493560-3804-kpg6q 6.12.105+ #1 SMP Sat Sep 5 07:54:11 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 fix-epoch-duration-fraction (e391b4d) to 353e4ce diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_epoch"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: "353e4cee59f9172d86d284bdc4e08989e4a05192"

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing fix-epoch-duration-fraction (e391b4d) to 353e4ce diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_epoch"
baseline:
  ref: "353e4cee59f9172d86d284bdc4e08989e4a05192"
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                                     HEAD                                   fix-epoch-duration-fraction
-----                                     ----                                   ---------------------------
date_part_epoch_date32_1000               1.00    544.9±1.17ns        ? ?/sec    1.02    555.1±2.62ns        ? ?/sec
date_part_epoch_date64_1000               1.01   1216.3±6.30ns        ? ?/sec    1.00   1203.6±3.42ns        ? ?/sec
date_part_epoch_duration_ns_1000          5.60      6.7±0.05µs        ? ?/sec    1.00   1203.1±2.13ns        ? ?/sec
date_part_epoch_duration_ns_nulls_1000    7.11      8.6±0.06µs        ? ?/sec    1.00   1210.1±5.03ns        ? ?/sec
date_part_epoch_duration_ns_small_1000    2.50      3.0±0.00µs        ? ?/sec    1.00   1214.4±2.65ns        ? ?/sec
date_part_epoch_interval_dt_1000          1.00   1219.8±2.08ns        ? ?/sec    1.00   1220.6±5.33ns        ? ?/sec
date_part_epoch_interval_mdn_1000         1.00   1303.8±1.37ns        ? ?/sec    1.01   1313.1±2.85ns        ? ?/sec
date_part_epoch_interval_ym_1000          1.01    605.6±2.82ns        ? ?/sec    1.00    602.4±2.45ns        ? ?/sec
date_part_epoch_ms_1000                   1.01   1210.3±0.76ns        ? ?/sec    1.00   1202.0±3.12ns        ? ?/sec
date_part_epoch_ns_1000                   1.00   1208.7±4.19ns        ? ?/sec    1.00   1203.9±2.25ns        ? ?/sec
date_part_epoch_s_1000                    1.00    411.6±2.00ns        ? ?/sec    1.01    415.3±2.87ns        ? ?/sec
date_part_epoch_time32_ms_1000            1.01   1209.2±3.72ns        ? ?/sec    1.00   1197.4±3.02ns        ? ?/sec
date_part_epoch_time32_s_1000             1.00    474.8±1.20ns        ? ?/sec    1.00    473.3±2.59ns        ? ?/sec
date_part_epoch_time64_ns_1000            1.00   1207.5±1.33ns        ? ?/sec    1.00   1202.2±2.09ns        ? ?/sec
date_part_epoch_time64_us_1000            1.01   1212.3±4.38ns        ? ?/sec    1.00   1196.8±3.55ns        ? ?/sec
date_part_epoch_us_1000                   1.00   1209.7±3.35ns        ? ?/sec    1.01   1218.3±3.84ns        ? ?/sec

Resource Usage

datetime_expressions — base (merge-base)

Metric Value
Wall time 350.1s
Peak memory 32.9 MiB
Avg memory 13.5 MiB
CPU user 196.5s
CPU sys 0.2s
Peak spill 0 B

datetime_expressions — branch

Metric Value
Wall time 345.1s
Peak memory 33.4 MiB
Avg memory 14.0 MiB
CPU user 202.3s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing fix-epoch-duration-fraction (e391b4d) to 353e4ce diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_epoch"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: "353e4cee59f9172d86d284bdc4e08989e4a05192"
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                                     HEAD                                   fix-epoch-duration-fraction
-----                                     ----                                   ---------------------------
date_part_epoch_date32_1000               1.00    541.9±1.05ns        ? ?/sec    1.00    539.8±1.11ns        ? ?/sec
date_part_epoch_date64_1000               1.01   1214.0±1.76ns        ? ?/sec    1.00   1205.4±1.20ns        ? ?/sec
date_part_epoch_duration_ns_1000          5.57      6.7±0.06µs        ? ?/sec    1.00   1206.4±3.18ns        ? ?/sec
date_part_epoch_duration_ns_nulls_1000    7.31      8.8±0.08µs        ? ?/sec    1.00   1208.1±2.75ns        ? ?/sec
date_part_epoch_duration_ns_small_1000    2.45      2.9±0.01µs        ? ?/sec    1.00   1205.1±0.90ns        ? ?/sec
date_part_epoch_interval_dt_1000          1.01   1222.4±3.07ns        ? ?/sec    1.00   1214.4±0.68ns        ? ?/sec
date_part_epoch_interval_mdn_1000         1.01   1310.7±1.42ns        ? ?/sec    1.00   1299.5±1.01ns        ? ?/sec
date_part_epoch_interval_ym_1000          1.01    608.7±1.29ns        ? ?/sec    1.00    601.3±3.19ns        ? ?/sec
date_part_epoch_ms_1000                   1.01   1211.2±1.77ns        ? ?/sec    1.00   1202.7±1.13ns        ? ?/sec
date_part_epoch_ns_1000                   1.01   1211.1±1.77ns        ? ?/sec    1.00   1204.7±0.94ns        ? ?/sec
date_part_epoch_s_1000                    1.00    414.2±1.86ns        ? ?/sec    1.04    430.9±1.85ns        ? ?/sec
date_part_epoch_time32_ms_1000            1.01   1211.7±0.61ns        ? ?/sec    1.00   1205.6±1.39ns        ? ?/sec
date_part_epoch_time32_s_1000             1.00    480.4±1.67ns        ? ?/sec    1.00    478.8±4.56ns        ? ?/sec
date_part_epoch_time64_ns_1000            1.01   1209.9±0.98ns        ? ?/sec    1.00   1203.8±4.85ns        ? ?/sec
date_part_epoch_time64_us_1000            1.00   1213.0±1.27ns        ? ?/sec    1.00   1210.7±4.33ns        ? ?/sec
date_part_epoch_us_1000                   1.01   1210.2±1.63ns        ? ?/sec    1.00   1204.0±0.92ns        ? ?/sec

Resource Usage

datetime_expressions — base (merge-base)

Metric Value
Wall time 470.1s
Peak memory 36.8 MiB
Avg memory 10.9 MiB
CPU user 199.6s
CPU sys 0.2s
Peak spill 0 B

datetime_expressions — branch

Metric Value
Wall time 420.1s
Peak memory 33.2 MiB
Avg memory 11.8 MiB
CPU user 200.3s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing fix-epoch-duration-fraction (e391b4d) to 353e4ce diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_epoch"
baseline:
  ref: "353e4cee59f9172d86d284bdc4e08989e4a05192"
resources:
  arch: "amd64"
CPU Details (lscpu)
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           52 bits physical, 57 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               GenuineIntel
Model name:                              INTEL(R) XEON(R) PLATINUM 8581C CPU @ 2.30GHz
CPU family:                              6
Model:                                   207
Thread(s) per core:                      2
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                2
BogoMIPS:                                4600.00
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd arat avx512vbmi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid cldemote movdiri movdir64b fsrm md_clear serialize tsxldtrk amx_bf16 avx512_fp16 amx_tile amx_int8 arch_capabilities
Hypervisor vendor:                       KVM
Virtualization type:                     full
L1d cache:                               384 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                16 MiB (8 instances)
L3 cache:                                260 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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                     HEAD                                   fix-epoch-duration-fraction
-----                                     ----                                   ---------------------------
date_part_epoch_date32_1000               1.10   458.2±12.02ns        ? ?/sec    1.00   414.7±23.65ns        ? ?/sec
date_part_epoch_date64_1000               1.14   906.2±15.63ns        ? ?/sec    1.00   794.2±43.34ns        ? ?/sec
date_part_epoch_duration_ns_1000          8.09      6.3±0.06µs        ? ?/sec    1.00   775.4±41.14ns        ? ?/sec
date_part_epoch_duration_ns_nulls_1000    12.08     9.5±0.20µs        ? ?/sec    1.00   789.3±46.83ns        ? ?/sec
date_part_epoch_duration_ns_small_1000    4.50      3.5±0.05µs        ? ?/sec    1.00   769.8±27.55ns        ? ?/sec
date_part_epoch_interval_dt_1000          1.15   927.9±13.98ns        ? ?/sec    1.00   808.6±43.58ns        ? ?/sec
date_part_epoch_interval_mdn_1000         1.14  1178.1±18.90ns        ? ?/sec    1.00  1030.2±68.96ns        ? ?/sec
date_part_epoch_interval_ym_1000          1.15   550.6±14.23ns        ? ?/sec    1.00   477.5±31.40ns        ? ?/sec
date_part_epoch_ms_1000                   1.12   921.2±39.72ns        ? ?/sec    1.00   825.8±43.56ns        ? ?/sec
date_part_epoch_ns_1000                   1.09   925.8±15.24ns        ? ?/sec    1.00   846.2±44.37ns        ? ?/sec
date_part_epoch_s_1000                    1.18   497.9±11.32ns        ? ?/sec    1.00   422.4±23.33ns        ? ?/sec
date_part_epoch_time32_ms_1000            1.17   944.4±20.98ns        ? ?/sec    1.00   809.1±45.66ns        ? ?/sec
date_part_epoch_time32_s_1000             1.18    429.9±8.56ns        ? ?/sec    1.00   365.1±17.55ns        ? ?/sec
date_part_epoch_time64_ns_1000            1.17   942.9±18.37ns        ? ?/sec    1.00   802.7±42.81ns        ? ?/sec
date_part_epoch_time64_us_1000            1.19   938.2±21.00ns        ? ?/sec    1.00   789.1±41.59ns        ? ?/sec
date_part_epoch_us_1000                   1.11   937.7±19.58ns        ? ?/sec    1.00   846.6±42.78ns        ? ?/sec

Resource Usage

datetime_expressions — base (merge-base)

Metric Value
Wall time 510.1s
Peak memory 40.1 MiB
Avg memory 10.2 MiB
CPU user 221.9s
CPU sys 0.2s
Peak spill 0 B

datetime_expressions — branch

Metric Value
Wall time 420.1s
Peak memory 59.7 MiB
Avg memory 10.6 MiB
CPU user 203.5s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing fix-epoch-duration-fraction (e391b4d) to 353e4ce diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_epoch"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: "353e4cee59f9172d86d284bdc4e08989e4a05192"
resources:
  arch: "amd64"
CPU Details (lscpu)
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           52 bits physical, 57 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               GenuineIntel
Model name:                              INTEL(R) XEON(R) PLATINUM 8581C CPU @ 2.30GHz
CPU family:                              6
Model:                                   207
Thread(s) per core:                      2
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                2
BogoMIPS:                                4600.00
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd arat avx512vbmi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid cldemote movdiri movdir64b fsrm md_clear serialize tsxldtrk amx_bf16 avx512_fp16 amx_tile amx_int8 arch_capabilities
Hypervisor vendor:                       KVM
Virtualization type:                     full
L1d cache:                               384 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                16 MiB (8 instances)
L3 cache:                                260 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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                     HEAD                                   fix-epoch-duration-fraction
-----                                     ----                                   ---------------------------
date_part_epoch_date32_1000               1.05   488.4±10.19ns        ? ?/sec    1.00    464.5±9.56ns        ? ?/sec
date_part_epoch_date64_1000               1.03   936.4±18.41ns        ? ?/sec    1.00   909.8±10.25ns        ? ?/sec
date_part_epoch_duration_ns_1000          6.95      6.3±0.25µs        ? ?/sec    1.00    909.5±8.81ns        ? ?/sec
date_part_epoch_duration_ns_nulls_1000    10.68     9.8±0.18µs        ? ?/sec    1.00   918.7±10.22ns        ? ?/sec
date_part_epoch_duration_ns_small_1000    3.53      3.2±0.06µs        ? ?/sec    1.00   909.7±10.39ns        ? ?/sec
date_part_epoch_interval_dt_1000          1.02   938.9±10.68ns        ? ?/sec    1.00    916.8±6.20ns        ? ?/sec
date_part_epoch_interval_mdn_1000         1.02  1193.6±14.17ns        ? ?/sec    1.00  1171.3±15.47ns        ? ?/sec
date_part_epoch_interval_ym_1000          1.05   558.1±10.11ns        ? ?/sec    1.00    532.6±6.39ns        ? ?/sec
date_part_epoch_ms_1000                   1.03   935.3±14.76ns        ? ?/sec    1.00    911.4±8.13ns        ? ?/sec
date_part_epoch_ns_1000                   1.03   937.0±17.82ns        ? ?/sec    1.00    906.6±8.52ns        ? ?/sec
date_part_epoch_s_1000                    1.07   504.6±13.36ns        ? ?/sec    1.00    472.0±4.64ns        ? ?/sec
date_part_epoch_time32_ms_1000            1.01    918.9±8.99ns        ? ?/sec    1.00   907.8±11.65ns        ? ?/sec
date_part_epoch_time32_s_1000             1.05    444.2±8.10ns        ? ?/sec    1.00    423.7±8.37ns        ? ?/sec
date_part_epoch_time64_ns_1000            1.03   931.6±12.14ns        ? ?/sec    1.00   906.2±10.70ns        ? ?/sec
date_part_epoch_time64_us_1000            1.02   928.9±12.87ns        ? ?/sec    1.00   910.7±11.20ns        ? ?/sec
date_part_epoch_us_1000                   1.04   937.7±15.30ns        ? ?/sec    1.00    905.8±8.95ns        ? ?/sec

Resource Usage

datetime_expressions — base (merge-base)

Metric Value
Wall time 520.1s
Peak memory 49.4 MiB
Avg memory 10.5 MiB
CPU user 223.7s
CPU sys 0.2s
Peak spill 0 B

datetime_expressions — branch

Metric Value
Wall time 440.1s
Peak memory 37.1 MiB
Avg memory 10.9 MiB
CPU user 218.4s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

@alamb alamb 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.

This is great -- thank you @mbutrovich

It is effectively fixing a bug by deleting code

Duration(_) => return seconds(array, Second),
Duration(Second) => as_duration_second_array(array)?.unary(|x| x as f64),
Duration(Millisecond) => {
as_duration_millisecond_array(array)?.unary(|x| x as f64 / 1_000_f64)

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.

that certainly looks much faster and simpler

Comment thread datafusion/sqllogictest/test_files/datetime/date_part.slt Outdated
@mbutrovich
mbutrovich enabled auto-merge October 23, 2026 19:46
@mbutrovich
mbutrovich added this pull request to the merge queue Oct 23, 2026
Merged via the queue into apache:main with commit 702803d Oct 23, 2026
45 checks passed
@mbutrovich
mbutrovich deleted the fix-epoch-duration-fraction branch October 23, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt) v56.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EXTRACT EPOCH inconsistently extracts fractional seconds

3 participants