Skip to content

fix: date_part sub-second parts and result nullability, reusing arrow kernels - #26686

Open
mbutrovich wants to merge 5 commits into
apache:mainfrom
mbutrovich:fix-extract-nanosecond-duration-interval
Open

mbutrovich wants to merge 5 commits into
apache:mainfrom
mbutrovich:fix-extract-nanosecond-duration-interval

Conversation

@mbutrovich

@mbutrovich mbutrovich commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

These fixes depend on each other. #26678 and #14738 come from the same NULL-as-zero branch. Fixing #14738 makes millisecond and microsecond of a long duration return NULL instead of a wrapped value. Without the #26685 fix, that NULL fails with declared as non-nullable on a non-nullable input, so fixing #14738 alone would replace a wrong result with an error.

What changes are included in this PR?

  • millisecond, microsecond and nanosecond share one function that reuses arrow's date_part and cast where they compute the right value.
  • A value that overflows the return type is NULL, as arrow already does for durations. Should overflow be an error instead? That would change other parts too, so I'd rather do it separately.
  • The integer parts of date_part and the Spark date_part are always nullable. epoch keeps the input's nullability.
  • The first commit (c920a5b) adds benchmark cases without the fix, so the benchmark bot can compare against it.
date-part-subsecond-bot

The benchmark bot measured Duration and Interval at 3.6x to 41.6x faster, times at 1.5x to 2.2x, and timestamps within noise.

Numbers

Speedups over c920a5b (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
nanosecond, Duration(ns), large values 28.73x 29.06x 29.10x 26.71x
nanosecond, Duration(ns), large values, nulls 32.18x 32.41x 41.62x 36.13x
nanosecond, Duration(ns), under 2.1 s 9.25x 9.41x 9.76x 8.99x
nanosecond, Interval(DayTime) 9.74x 9.60x 6.20x 5.97x
nanosecond, Interval(MonthDayNano) 6.53x 6.48x 8.72x 7.55x
millisecond, Interval(DayTime) 9.22x 9.61x 8.29x 7.96x
microsecond, Duration(ns), under 2.1 s 5.16x 5.38x 3.64x 3.50x
microsecond, Time64(ns) 2.18x 2.24x 1.53x 1.61x
millisecond, Timestamp(ns) 1.11x 1.12x 1.08x 1.07x
nanosecond, Timestamp(ns) (unchanged) 0.99x 1.00x 0.98x 1.00x
second, Timestamp(ns) (unchanged) 1.00x 1.00x 1.00x 1.06x

In the default Xeon run the unchanged second cases are 0.98x to 1.08x, so gains in that range on timestamps are noise.

What is the testing strategy for this PR?

  • New cases in datafusion/sqllogictest/test_files/datetime/date_part.slt.
  • A unit test in datafusion/functions/src/datetime/date_part.rs.
  • A unit test in datafusion/spark/src/function/datetime/date_part.rs.

Are there any user-facing changes?

EXTRACT(MILLISECOND/MICROSECOND/NANOSECOND) on Duration and Interval return correct results. A Duration whose total in the requested unit overflows the return type returns NULL, as the other Duration parts already do, instead of a wrapped value or a panic. The integer results of date_part and the Spark date_part are nullable even for non-null input. 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.

@mbutrovich mbutrovich self-assigned this Oct 23, 2026
@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation spark Changes to datafusion-spark crate labels Oct 23, 2026
@mbutrovich

Copy link
Copy Markdown
Contributor Author

run benchmark datetime_expressions

env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
baseline:
  ref: c920a5b92df0172b23026c3773dc7cd0fbdb8ce6

@mbutrovich

Copy link
Copy Markdown
Contributor Author

run benchmark datetime_expressions

env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
baseline:
  ref: c920a5b92df0172b23026c3773dc7cd0fbdb8ce6
resources:
  arch: amd64

@mbutrovich

Copy link
Copy Markdown
Contributor Author

run benchmark datetime_expressions

env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: c920a5b92df0172b23026c3773dc7cd0fbdb8ce6

@mbutrovich

Copy link
Copy Markdown
Contributor Author

run benchmark datetime_expressions

env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: c920a5b92df0172b23026c3773dc7cd0fbdb8ce6
resources:
  arch: amd64

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c6375349435-3809-phgtw 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-extract-nanosecond-duration-interval (adab085) to c920a5b diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
baseline:
  ref: "c920a5b92df0172b23026c3773dc7cd0fbdb8ce6"

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-c6375352980-3811-5q2pc 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-extract-nanosecond-duration-interval (adab085) to c920a5b diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: "c920a5b92df0172b23026c3773dc7cd0fbdb8ce6"

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-c6375351277-3810-nwzn8 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-extract-nanosecond-duration-interval (adab085) to c920a5b diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
baseline:
  ref: "c920a5b92df0172b23026c3773dc7cd0fbdb8ce6"
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-c6375354681-3812-68qz6 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-extract-nanosecond-duration-interval (adab085) to c920a5b diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: "c920a5b92df0172b23026c3773dc7cd0fbdb8ce6"
resources:
  arch: "amd64"

Results will be posted here when complete


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-extract-nanosecond-duration-interval (adab085) to c920a5b diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
baseline:
  ref: "c920a5b92df0172b23026c3773dc7cd0fbdb8ce6"
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-extract-nanosecond-duration-interval
-----                                           ----                                   ----------------------------------------
date_part_microsecond_date32_1000               1.03    245.0±2.23ns        ? ?/sec    1.00    236.9±2.53ns        ? ?/sec
date_part_microsecond_date64_1000               1.04    245.6±1.22ns        ? ?/sec    1.00    235.8±2.48ns        ? ?/sec
date_part_microsecond_duration_ns_small_1000    3.64      3.2±0.02µs        ? ?/sec    1.00   867.2±10.56ns        ? ?/sec
date_part_microsecond_interval_dt_1000          6.39      6.2±0.07µs        ? ?/sec    1.00   977.4±16.36ns        ? ?/sec
date_part_microsecond_interval_mdn_1000         5.83      6.5±0.15µs        ? ?/sec    1.00  1117.8±14.44ns        ? ?/sec
date_part_microsecond_ms_1000                   1.07     19.5±0.11µs        ? ?/sec    1.00     18.3±0.35µs        ? ?/sec
date_part_microsecond_ns_1000                   1.07     18.7±0.08µs        ? ?/sec    1.00     17.5±0.12µs        ? ?/sec
date_part_microsecond_ns_tz_1000                1.04     84.0±1.76µs        ? ?/sec    1.00     81.1±0.67µs        ? ?/sec
date_part_microsecond_s_1000                    1.21      9.0±0.09µs        ? ?/sec    1.00      7.5±0.05µs        ? ?/sec
date_part_microsecond_time32_ms_1000            1.69      3.8±0.03µs        ? ?/sec    1.00      2.3±0.01µs        ? ?/sec
date_part_microsecond_time64_ns_1000            1.53      3.6±0.02µs        ? ?/sec    1.00      2.4±0.05µs        ? ?/sec
date_part_microsecond_us_1000                   1.07     19.8±0.11µs        ? ?/sec    1.00     18.6±0.13µs        ? ?/sec
date_part_millisecond_date32_1000               1.04    245.5±1.85ns        ? ?/sec    1.00    235.1±4.28ns        ? ?/sec
date_part_millisecond_date64_1000               1.04    245.3±2.09ns        ? ?/sec    1.00    235.1±2.18ns        ? ?/sec
date_part_millisecond_duration_ns_small_1000    3.83      3.1±0.03µs        ? ?/sec    1.00    813.7±6.18ns        ? ?/sec
date_part_millisecond_interval_dt_1000          8.29      6.2±0.03µs        ? ?/sec    1.00    750.3±6.78ns        ? ?/sec
date_part_millisecond_interval_mdn_1000         5.14      6.5±0.08µs        ? ?/sec    1.00  1273.2±27.35ns        ? ?/sec
date_part_millisecond_ms_1000                   1.06     19.5±0.10µs        ? ?/sec    1.00     18.4±0.19µs        ? ?/sec
date_part_millisecond_ns_1000                   1.08     18.8±0.13µs        ? ?/sec    1.00     17.4±0.14µs        ? ?/sec
date_part_millisecond_ns_tz_1000                1.04     83.8±0.65µs        ? ?/sec    1.00     80.5±0.92µs        ? ?/sec
date_part_millisecond_s_1000                    1.20      9.0±0.07µs        ? ?/sec    1.00      7.5±0.05µs        ? ?/sec
date_part_millisecond_time32_ms_1000            1.91      3.8±0.04µs        ? ?/sec    1.00      2.0±0.03µs        ? ?/sec
date_part_millisecond_time64_ns_1000            1.58      3.6±0.02µs        ? ?/sec    1.00      2.3±0.03µs        ? ?/sec
date_part_millisecond_us_1000                   1.07     19.9±0.13µs        ? ?/sec    1.00     18.6±0.14µs        ? ?/sec
date_part_nanosecond_date32_1000                1.03    258.5±1.57ns        ? ?/sec    1.00    250.0±1.85ns        ? ?/sec
date_part_nanosecond_date64_1000                1.04    260.1±2.83ns        ? ?/sec    1.00    249.0±1.03ns        ? ?/sec
date_part_nanosecond_duration_ns_1000           29.10     4.9±0.03µs        ? ?/sec    1.00    169.9±2.19ns        ? ?/sec
date_part_nanosecond_duration_ns_nulls_1000     41.62     7.9±0.04µs        ? ?/sec    1.00    190.7±3.09ns        ? ?/sec
date_part_nanosecond_duration_ns_small_1000     9.76   1655.0±7.95ns        ? ?/sec    1.00    169.5±1.64ns        ? ?/sec
date_part_nanosecond_interval_dt_1000           6.20      5.9±0.04µs        ? ?/sec    1.00   955.6±10.00ns        ? ?/sec
date_part_nanosecond_interval_mdn_1000          8.72      6.2±0.05µs        ? ?/sec    1.00    716.7±8.71ns        ? ?/sec
date_part_nanosecond_ms_1000                    1.00     18.1±0.20µs        ? ?/sec    1.02     18.4±0.28µs        ? ?/sec
date_part_nanosecond_ns_1000                    1.00     17.3±0.16µs        ? ?/sec    1.02     17.6±0.14µs        ? ?/sec
date_part_nanosecond_ns_tz_1000                 1.01     82.2±0.33µs        ? ?/sec    1.00     81.0±0.58µs        ? ?/sec
date_part_nanosecond_s_1000                     1.00      7.5±0.05µs        ? ?/sec    1.02      7.7±0.10µs        ? ?/sec
date_part_nanosecond_time32_ms_1000             1.00      2.4±0.02µs        ? ?/sec    1.03      2.4±0.02µs        ? ?/sec
date_part_nanosecond_time64_ns_1000             1.00      2.1±0.01µs        ? ?/sec    1.03      2.2±0.04µs        ? ?/sec
date_part_nanosecond_us_1000                    1.00     18.3±0.13µs        ? ?/sec    1.02     18.8±0.22µs        ? ?/sec
date_part_second_date32_1000                    1.08    254.6±3.25ns        ? ?/sec    1.00    235.8±2.20ns        ? ?/sec
date_part_second_date64_1000                    1.00      9.0±0.06µs        ? ?/sec    1.02      9.2±0.08µs        ? ?/sec
date_part_second_ms_1000                        1.00      9.0±0.06µs        ? ?/sec    1.02      9.2±0.10µs        ? ?/sec
date_part_second_ns_1000                        1.00      8.7±0.06µs        ? ?/sec    1.00      8.7±0.07µs        ? ?/sec
date_part_second_s_1000                         1.00      7.1±0.10µs        ? ?/sec    1.01      7.1±0.03µs        ? ?/sec
date_part_second_us_1000                        1.00      9.2±0.06µs        ? ?/sec    1.01      9.3±0.06µs        ? ?/sec

Resource Usage

datetime_expressions — base (merge-base)

Metric Value
Wall time 650.2s
Peak memory 102.7 MiB
Avg memory 25.5 MiB
CPU user 587.0s
CPU sys 0.4s
Peak spill 0 B

datetime_expressions — branch

Metric Value
Wall time 650.2s
Peak memory 42.3 MiB
Avg memory 25.7 MiB
CPU user 592.1s
CPU sys 0.4s
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-extract-nanosecond-duration-interval (adab085) to c920a5b diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
baseline:
  ref: "c920a5b92df0172b23026c3773dc7cd0fbdb8ce6"
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-extract-nanosecond-duration-interval
-----                                           ----                                   ----------------------------------------
date_part_microsecond_date32_1000               1.06    343.2±0.56ns        ? ?/sec    1.00    322.8±4.68ns        ? ?/sec
date_part_microsecond_date64_1000               1.06    344.9±1.16ns        ? ?/sec    1.00    325.7±4.96ns        ? ?/sec
date_part_microsecond_duration_ns_small_1000    5.16      5.5±0.01µs        ? ?/sec    1.00   1060.2±3.97ns        ? ?/sec
date_part_microsecond_interval_dt_1000          8.75      7.5±0.06µs        ? ?/sec    1.00    858.7±3.98ns        ? ?/sec
date_part_microsecond_interval_mdn_1000         4.62      8.3±0.07µs        ? ?/sec    1.00   1799.0±4.43ns        ? ?/sec
date_part_microsecond_ms_1000                   1.17     23.5±0.03µs        ? ?/sec    1.00     20.2±0.03µs        ? ?/sec
date_part_microsecond_ns_1000                   1.17     21.8±0.03µs        ? ?/sec    1.00     18.7±0.01µs        ? ?/sec
date_part_microsecond_ns_tz_1000                1.09     94.7±0.50µs        ? ?/sec    1.00     86.5±0.22µs        ? ?/sec
date_part_microsecond_s_1000                    1.27     10.4±0.01µs        ? ?/sec    1.00      8.2±0.02µs        ? ?/sec
date_part_microsecond_time32_ms_1000            2.35      6.0±0.01µs        ? ?/sec    1.00      2.6±0.00µs        ? ?/sec
date_part_microsecond_time64_ns_1000            2.18      6.0±0.12µs        ? ?/sec    1.00      2.7±0.00µs        ? ?/sec
date_part_microsecond_us_1000                   1.16     22.3±0.02µs        ? ?/sec    1.00     19.2±0.08µs        ? ?/sec
date_part_millisecond_date32_1000               1.05    349.5±0.89ns        ? ?/sec    1.00    332.5±3.50ns        ? ?/sec
date_part_millisecond_date64_1000               1.08    356.7±3.84ns        ? ?/sec    1.00    331.1±4.06ns        ? ?/sec
date_part_millisecond_duration_ns_small_1000    3.94      4.7±0.01µs        ? ?/sec    1.00   1180.7±3.22ns        ? ?/sec
date_part_millisecond_interval_dt_1000          9.22      7.5±0.07µs        ? ?/sec    1.00    811.2±4.80ns        ? ?/sec
date_part_millisecond_interval_mdn_1000         4.59      8.4±0.06µs        ? ?/sec    1.00   1820.1±5.29ns        ? ?/sec
date_part_millisecond_ms_1000                   1.13     22.7±0.04µs        ? ?/sec    1.00     20.1±0.04µs        ? ?/sec
date_part_millisecond_ns_1000                   1.11     21.0±0.02µs        ? ?/sec    1.00     19.0±0.03µs        ? ?/sec
date_part_millisecond_ns_tz_1000                1.06     93.2±0.26µs        ? ?/sec    1.00     87.5±0.40µs        ? ?/sec
date_part_millisecond_s_1000                    1.29     10.5±0.01µs        ? ?/sec    1.00      8.2±0.01µs        ? ?/sec
date_part_millisecond_time32_ms_1000            2.17      5.3±0.01µs        ? ?/sec    1.00      2.4±0.01µs        ? ?/sec
date_part_millisecond_time64_ns_1000            1.83      5.2±0.01µs        ? ?/sec    1.00      2.8±0.00µs        ? ?/sec
date_part_millisecond_us_1000                   1.12     21.6±0.02µs        ? ?/sec    1.00     19.3±0.03µs        ? ?/sec
date_part_nanosecond_date32_1000                1.04    379.3±0.65ns        ? ?/sec    1.00    364.6±3.40ns        ? ?/sec
date_part_nanosecond_date64_1000                1.07    381.9±0.87ns        ? ?/sec    1.00    356.8±3.40ns        ? ?/sec
date_part_nanosecond_duration_ns_1000           28.73     6.5±0.05µs        ? ?/sec    1.00    227.4±3.11ns        ? ?/sec
date_part_nanosecond_duration_ns_nulls_1000     32.18     8.4±0.09µs        ? ?/sec    1.00    260.3±2.85ns        ? ?/sec
date_part_nanosecond_duration_ns_small_1000     9.25      2.1±0.00µs        ? ?/sec    1.00    226.2±3.32ns        ? ?/sec
date_part_nanosecond_interval_dt_1000           9.74      7.1±0.05µs        ? ?/sec    1.00    724.6±3.91ns        ? ?/sec
date_part_nanosecond_interval_mdn_1000          6.53      7.9±0.05µs        ? ?/sec    1.00   1216.0±3.83ns        ? ?/sec
date_part_nanosecond_ms_1000                    1.01     20.2±0.09µs        ? ?/sec    1.00     20.0±0.02µs        ? ?/sec
date_part_nanosecond_ns_1000                    1.00     18.5±0.03µs        ? ?/sec    1.01     18.7±0.10µs        ? ?/sec
date_part_nanosecond_ns_tz_1000                 1.04     91.0±0.34µs        ? ?/sec    1.00     87.6±0.24µs        ? ?/sec
date_part_nanosecond_s_1000                     1.00      8.2±0.01µs        ? ?/sec    1.00      8.3±0.01µs        ? ?/sec
date_part_nanosecond_time32_ms_1000             1.06      2.6±0.01µs        ? ?/sec    1.00      2.5±0.00µs        ? ?/sec
date_part_nanosecond_time64_ns_1000             1.00      2.6±0.01µs        ? ?/sec    1.05      2.7±0.00µs        ? ?/sec
date_part_nanosecond_us_1000                    1.01     19.3±0.02µs        ? ?/sec    1.00     19.1±0.08µs        ? ?/sec
date_part_second_date32_1000                    1.00    351.4±1.90ns        ? ?/sec    1.00    351.6±3.42ns        ? ?/sec
date_part_second_date64_1000                    1.00     10.3±0.01µs        ? ?/sec    1.00     10.3±0.01µs        ? ?/sec
date_part_second_ms_1000                        1.00     10.2±0.01µs        ? ?/sec    1.00     10.2±0.01µs        ? ?/sec
date_part_second_ns_1000                        1.00      9.6±0.02µs        ? ?/sec    1.00      9.6±0.01µs        ? ?/sec
date_part_second_s_1000                         1.01      7.7±0.01µs        ? ?/sec    1.00      7.6±0.01µs        ? ?/sec
date_part_second_us_1000                        1.00      9.7±0.01µs        ? ?/sec    1.02      9.9±0.03µs        ? ?/sec

Resource Usage

datetime_expressions — base (merge-base)

Metric Value
Wall time 675.1s
Peak memory 34.8 MiB
Avg memory 21.2 MiB
CPU user 550.0s
CPU sys 0.6s
Peak spill 0 B

datetime_expressions — branch

Metric Value
Wall time 680.1s
Peak memory 38.0 MiB
Avg memory 23.4 MiB
CPU user 558.7s
CPU sys 0.5s
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-extract-nanosecond-duration-interval (adab085) to c920a5b diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: "c920a5b92df0172b23026c3773dc7cd0fbdb8ce6"
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-extract-nanosecond-duration-interval
-----                                           ----                                   ----------------------------------------
date_part_microsecond_date32_1000               1.05    354.6±1.31ns        ? ?/sec    1.00    336.3±1.03ns        ? ?/sec
date_part_microsecond_date64_1000               1.08    359.5±1.60ns        ? ?/sec    1.00    333.5±1.08ns        ? ?/sec
date_part_microsecond_duration_ns_small_1000    5.38      5.5±0.01µs        ? ?/sec    1.00   1020.3±2.71ns        ? ?/sec
date_part_microsecond_interval_dt_1000          9.17      7.5±0.09µs        ? ?/sec    1.00    815.6±3.04ns        ? ?/sec
date_part_microsecond_interval_mdn_1000         4.70      8.3±0.09µs        ? ?/sec    1.00   1766.3±3.75ns        ? ?/sec
date_part_microsecond_ms_1000                   1.17     23.6±0.02µs        ? ?/sec    1.00     20.3±0.02µs        ? ?/sec
date_part_microsecond_ns_1000                   1.17     21.9±0.01µs        ? ?/sec    1.00     18.7±0.01µs        ? ?/sec
date_part_microsecond_ns_tz_1000                1.06     93.8±0.26µs        ? ?/sec    1.00     88.4±0.26µs        ? ?/sec
date_part_microsecond_s_1000                    1.29     10.5±0.01µs        ? ?/sec    1.00      8.2±0.01µs        ? ?/sec
date_part_microsecond_time32_ms_1000            2.34      6.0±0.00µs        ? ?/sec    1.00      2.6±0.00µs        ? ?/sec
date_part_microsecond_time64_ns_1000            2.24      6.0±0.01µs        ? ?/sec    1.00      2.7±0.00µs        ? ?/sec
date_part_microsecond_us_1000                   1.18     22.4±0.11µs        ? ?/sec    1.00     19.1±0.01µs        ? ?/sec
date_part_millisecond_date32_1000               1.04    352.5±1.20ns        ? ?/sec    1.00    339.2±1.52ns        ? ?/sec
date_part_millisecond_date64_1000               1.11    353.7±1.29ns        ? ?/sec    1.00    317.5±0.64ns        ? ?/sec
date_part_millisecond_duration_ns_small_1000    4.62      4.7±0.01µs        ? ?/sec    1.00   1012.6±2.71ns        ? ?/sec
date_part_millisecond_interval_dt_1000          9.61      7.4±0.09µs        ? ?/sec    1.00    774.9±7.59ns        ? ?/sec
date_part_millisecond_interval_mdn_1000         4.69      8.3±0.10µs        ? ?/sec    1.00   1770.4±3.52ns        ? ?/sec
date_part_millisecond_ms_1000                   1.11     22.5±0.02µs        ? ?/sec    1.00     20.4±0.17µs        ? ?/sec
date_part_millisecond_ns_1000                   1.12     21.1±0.05µs        ? ?/sec    1.00     18.9±0.02µs        ? ?/sec
date_part_millisecond_ns_tz_1000                1.06     94.0±0.35µs        ? ?/sec    1.00     88.3±0.15µs        ? ?/sec
date_part_millisecond_s_1000                    1.27     10.5±0.01µs        ? ?/sec    1.00      8.3±0.01µs        ? ?/sec
date_part_millisecond_time32_ms_1000            2.11      5.2±0.01µs        ? ?/sec    1.00      2.5±0.00µs        ? ?/sec
date_part_millisecond_time64_ns_1000            1.95      5.2±0.01µs        ? ?/sec    1.00      2.6±0.00µs        ? ?/sec
date_part_millisecond_us_1000                   1.13     21.6±0.02µs        ? ?/sec    1.00     19.1±0.02µs        ? ?/sec
date_part_nanosecond_date32_1000                1.06    384.1±1.36ns        ? ?/sec    1.00    363.1±0.96ns        ? ?/sec
date_part_nanosecond_date64_1000                1.07    386.6±1.21ns        ? ?/sec    1.00    360.8±0.82ns        ? ?/sec
date_part_nanosecond_duration_ns_1000           29.06     6.5±0.06µs        ? ?/sec    1.00    224.7±0.65ns        ? ?/sec
date_part_nanosecond_duration_ns_nulls_1000     32.41     8.4±0.06µs        ? ?/sec    1.00    259.5±1.06ns        ? ?/sec
date_part_nanosecond_duration_ns_small_1000     9.41      2.1±0.00µs        ? ?/sec    1.00    227.5±0.83ns        ? ?/sec
date_part_nanosecond_interval_dt_1000           9.60      7.0±0.06µs        ? ?/sec    1.00    731.4±0.93ns        ? ?/sec
date_part_nanosecond_interval_mdn_1000          6.48      7.9±0.07µs        ? ?/sec    1.00   1219.2±0.94ns        ? ?/sec
date_part_nanosecond_ms_1000                    1.00     20.2±0.03µs        ? ?/sec    1.00     20.2±0.02µs        ? ?/sec
date_part_nanosecond_ns_1000                    1.00     18.5±0.01µs        ? ?/sec    1.00     18.4±0.02µs        ? ?/sec
date_part_nanosecond_ns_tz_1000                 1.04     91.7±0.36µs        ? ?/sec    1.00     88.2±0.38µs        ? ?/sec
date_part_nanosecond_s_1000                     1.00      8.3±0.01µs        ? ?/sec    1.00      8.3±0.03µs        ? ?/sec
date_part_nanosecond_time32_ms_1000             1.01      2.6±0.00µs        ? ?/sec    1.00      2.5±0.00µs        ? ?/sec
date_part_nanosecond_time64_ns_1000             1.02      2.6±0.00µs        ? ?/sec    1.00      2.5±0.00µs        ? ?/sec
date_part_nanosecond_us_1000                    1.00     19.1±0.03µs        ? ?/sec    1.00     19.0±0.02µs        ? ?/sec
date_part_second_date32_1000                    1.02    358.6±2.06ns        ? ?/sec    1.00    351.2±1.35ns        ? ?/sec
date_part_second_date64_1000                    1.00     10.3±0.05µs        ? ?/sec    1.01     10.4±0.03µs        ? ?/sec
date_part_second_ms_1000                        1.00     10.3±0.02µs        ? ?/sec    1.00     10.2±0.03µs        ? ?/sec
date_part_second_ns_1000                        1.00      9.6±0.01µs        ? ?/sec    1.00      9.6±0.01µs        ? ?/sec
date_part_second_s_1000                         1.01      7.8±0.01µs        ? ?/sec    1.00      7.7±0.02µs        ? ?/sec
date_part_second_us_1000                        1.00      9.7±0.02µs        ? ?/sec    1.01      9.8±0.01µs        ? ?/sec

Resource Usage

datetime_expressions — base (merge-base)

Metric Value
Wall time 675.1s
Peak memory 35.4 MiB
Avg memory 20.8 MiB
CPU user 546.9s
CPU sys 0.5s
Peak spill 0 B

datetime_expressions — branch

Metric Value
Wall time 675.2s
Peak memory 35.6 MiB
Avg memory 21.5 MiB
CPU user 549.7s
CPU sys 0.5s
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-extract-nanosecond-duration-interval (adab085) to c920a5b diff

Run configuration
run benchmark datetime_expressions
env:
  BENCH_FILTER: "date_part_(second|millisecond|microsecond|nanosecond)_"
  RUSTFLAGS: "-C llvm-args=-align-all-functions=6 -C llvm-args=-align-all-nofallthru-blocks=6"
baseline:
  ref: "c920a5b92df0172b23026c3773dc7cd0fbdb8ce6"
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-extract-nanosecond-duration-interval
-----                                           ----                                   ----------------------------------------
date_part_microsecond_date32_1000               1.07    308.1±6.40ns        ? ?/sec    1.00    287.0±8.12ns        ? ?/sec
date_part_microsecond_date64_1000               1.07    309.0±8.24ns        ? ?/sec    1.00    287.8±8.71ns        ? ?/sec
date_part_microsecond_duration_ns_small_1000    3.50      3.8±0.18µs        ? ?/sec    1.00   1083.6±8.25ns        ? ?/sec
date_part_microsecond_interval_dt_1000          5.97      7.8±0.19µs        ? ?/sec    1.00  1306.3±26.01ns        ? ?/sec
date_part_microsecond_interval_mdn_1000         5.22      8.1±0.21µs        ? ?/sec    1.00  1559.9±32.86ns        ? ?/sec
date_part_microsecond_ms_1000                   1.09     24.6±0.62µs        ? ?/sec    1.00     22.6±0.58µs        ? ?/sec
date_part_microsecond_ns_1000                   1.08     23.4±0.63µs        ? ?/sec    1.00     21.7±0.50µs        ? ?/sec
date_part_microsecond_ns_tz_1000                1.00    105.5±1.83µs        ? ?/sec    1.00    105.7±2.55µs        ? ?/sec
date_part_microsecond_s_1000                    1.22     11.3±0.56µs        ? ?/sec    1.00      9.3±0.24µs        ? ?/sec
date_part_microsecond_time32_ms_1000            1.61      4.9±0.12µs        ? ?/sec    1.00      3.0±0.06µs        ? ?/sec
date_part_microsecond_time64_ns_1000            1.61      4.7±0.09µs        ? ?/sec    1.00      2.9±0.06µs        ? ?/sec
date_part_microsecond_us_1000                   1.08     24.8±0.79µs        ? ?/sec    1.00     23.0±0.93µs        ? ?/sec
date_part_millisecond_date32_1000               1.05    307.1±8.48ns        ? ?/sec    1.00    293.8±7.15ns        ? ?/sec
date_part_millisecond_date64_1000               1.00    300.4±8.25ns        ? ?/sec    1.03    309.7±8.91ns        ? ?/sec
date_part_millisecond_duration_ns_small_1000    3.86      4.0±0.12µs        ? ?/sec    1.00  1024.5±26.89ns        ? ?/sec
date_part_millisecond_interval_dt_1000          7.96      7.6±0.27µs        ? ?/sec    1.00   950.1±36.13ns        ? ?/sec
date_part_millisecond_interval_mdn_1000         5.23      7.8±0.27µs        ? ?/sec    1.00  1491.1±61.65ns        ? ?/sec
date_part_millisecond_ms_1000                   1.08     24.0±0.87µs        ? ?/sec    1.00     22.3±0.50µs        ? ?/sec
date_part_millisecond_ns_1000                   1.07     23.2±0.38µs        ? ?/sec    1.00     21.6±0.52µs        ? ?/sec
date_part_millisecond_ns_tz_1000                1.02    105.9±3.06µs        ? ?/sec    1.00    104.0±3.19µs        ? ?/sec
date_part_millisecond_s_1000                    1.21     10.9±0.42µs        ? ?/sec    1.00      9.0±0.33µs        ? ?/sec
date_part_millisecond_time32_ms_1000            1.91      4.8±0.10µs        ? ?/sec    1.00      2.5±0.10µs        ? ?/sec
date_part_millisecond_time64_ns_1000            1.60      4.5±0.08µs        ? ?/sec    1.00      2.8±0.09µs        ? ?/sec
date_part_millisecond_us_1000                   1.11     24.6±0.53µs        ? ?/sec    1.00     22.2±0.97µs        ? ?/sec
date_part_nanosecond_date32_1000                1.07    339.0±7.36ns        ? ?/sec    1.00   317.6±11.01ns        ? ?/sec
date_part_nanosecond_date64_1000                1.07    339.8±6.07ns        ? ?/sec    1.00   317.2±10.93ns        ? ?/sec
date_part_nanosecond_duration_ns_1000           26.71     6.0±0.34µs        ? ?/sec    1.00   225.7±10.79ns        ? ?/sec
date_part_nanosecond_duration_ns_nulls_1000     36.13     9.0±0.36µs        ? ?/sec    1.00    250.4±6.24ns        ? ?/sec
date_part_nanosecond_duration_ns_small_1000     8.99      2.0±0.11µs        ? ?/sec    1.00    223.2±5.16ns        ? ?/sec
date_part_nanosecond_interval_dt_1000           5.97      7.3±0.32µs        ? ?/sec    1.00  1220.9±21.83ns        ? ?/sec
date_part_nanosecond_interval_mdn_1000          7.55      7.3±0.29µs        ? ?/sec    1.00   971.9±17.34ns        ? ?/sec
date_part_nanosecond_ms_1000                    1.00     22.4±0.51µs        ? ?/sec    1.00     22.3±0.78µs        ? ?/sec
date_part_nanosecond_ns_1000                    1.00     21.3±0.77µs        ? ?/sec    1.00     21.3±0.60µs        ? ?/sec
date_part_nanosecond_ns_tz_1000                 1.00    101.2±2.58µs        ? ?/sec    1.10    110.9±1.84µs        ? ?/sec
date_part_nanosecond_s_1000                     1.02      9.6±0.20µs        ? ?/sec    1.00      9.3±0.22µs        ? ?/sec
date_part_nanosecond_time32_ms_1000             1.00      3.0±0.09µs        ? ?/sec    1.01      3.0±0.07µs        ? ?/sec
date_part_nanosecond_time64_ns_1000             1.00      2.7±0.07µs        ? ?/sec    1.00      2.7±0.05µs        ? ?/sec
date_part_nanosecond_us_1000                    1.03     22.7±0.41µs        ? ?/sec    1.00     22.0±0.99µs        ? ?/sec
date_part_second_date32_1000                    1.01   318.0±11.02ns        ? ?/sec    1.00   314.2±15.50ns        ? ?/sec
date_part_second_date64_1000                    1.05     11.3±0.25µs        ? ?/sec    1.00     10.8±0.58µs        ? ?/sec
date_part_second_ms_1000                        1.05     11.3±0.24µs        ? ?/sec    1.00     10.8±0.53µs        ? ?/sec
date_part_second_ns_1000                        1.06     10.7±0.23µs        ? ?/sec    1.00     10.1±0.51µs        ? ?/sec
date_part_second_s_1000                         1.00      8.5±0.33µs        ? ?/sec    1.01      8.6±0.21µs        ? ?/sec
date_part_second_us_1000                        1.03     11.3±0.34µs        ? ?/sec    1.00     11.0±0.39µs        ? ?/sec

Resource Usage

datetime_expressions — base (merge-base)

Metric Value
Wall time 710.2s
Peak memory 44.4 MiB
Avg memory 25.0 MiB
CPU user 644.3s
CPU sys 0.5s
Peak spill 0 B

datetime_expressions — branch

Metric Value
Wall time 705.2s
Peak memory 46.0 MiB
Avg memory 24.2 MiB
CPU user 653.4s
CPU sys 0.5s
Peak spill 0 B

File an issue against this benchmark runner

@mbutrovich
mbutrovich marked this pull request as ready for review October 23, 2026 22:27
@mbutrovich
mbutrovich marked this pull request as draft October 23, 2026 22:33
@mbutrovich
mbutrovich marked this pull request as ready for review October 23, 2026 22:50

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

Thanks for tying the three issues together. Reusing arrow's kernels for intervals and durations is a clear improvement, and the bench commit makes the speedups easy to check. A few points inline. Small ones:

  • The doc on subsecond_part still explains Int64 by the 60-second bound. After this PR nanosecond on a Duration is its total length, up to i64::MAX, so that sentence covers only half of the cases now.
  • Coverage gaps worth one query each: nanosecond on a MonthDayNano past minus one minute (only -1.5 s is tested, and the % 60_000_000_000 arm is new), nanosecond on a negative DayTime and one with a non-zero days field, Timestamp(Microsecond) sub-second parts, and Time32/Time64 sub-second parts on an array with a NULL row. seconds_with_fraction is now the only path for times, and every existing time test is a single non-null literal.

Comment on lines +1512 to +1515
# Reproducer from https://github.com/apache/datafusion/issues/14738: 2.4e9 microseconds don't fit in Int32
query I
SELECT date_part('microsecond', timestamp '1970-01-01T00:40:00' - timestamp '1970-01-01T00:00:00')
----

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 the query from #14738, which asks for the Postgres result. In Postgres timestamp - timestamp is an interval and microsecond is the seconds field within the minute, so the issue expects 0. Here the difference is a Duration, and microsecond is its total length. Any duration longer than about 35.8 minutes is then NULL, and millisecond is NULL past about 24.8 days.

That matches how arrow treats the other Duration parts, so I think it is defensible. But it is a third answer to the issue, after the wrapped value and the panic. Should this be Part of #14738, with the semantics question left open? Or is NULL the agreed outcome? If total length is the intended meaning, a follow-up could return Int64 for Duration input, since return_field_from_args sees the input type. That would avoid most of these NULLs.

Comment on lines +534 to +541
(Duration(Nanosecond), DatePart::Nanosecond) => {
Arc::new(as_duration_nanosecond_array(array)?.reinterpret_cast::<Int64Type>())
}
// arrow's cast returns NULL on overflow, like its `date_part`
(Duration(_), DatePart::Nanosecond) => Arc::new(
as_duration_nanosecond_array(&cast(array, &Duration(Nanosecond))?)?
.reinterpret_cast::<Int64Type>(),
),

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.

These two arms can be one:

(Duration(_), DatePart::Nanosecond) => {
    cast(&cast(array, &Duration(Nanosecond))?, &DataType::Int64)?
}

arrow's cast returns the input as is when the types already match. It reinterprets Duration(Nanosecond) as Int64 without copying, and it already turns overflow into NULL for the unit change. That removes an arm and the repeated as_duration_nanosecond_array(..)?.reinterpret_cast::<Int64Type>() pair.

Comment on lines +544 to +548
(
Interval(ArrowIntervalUnit::DayTime | ArrowIntervalUnit::MonthDayNano)
| Duration(_),
_,
) => date_part(array, part)?,

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.

Could this be Interval(_) | Duration(_)? Today Interval(YearMonth) with millisecond or microsecond falls through to seconds_with_fraction, whose doc says it is for timestamps and times. It then fails on its first date_part(.., Second), so extract(millisecond ..) reports Second does not support: Interval(YearMonth) (the slt at L1288 and L1291 pins this). arrow's YearMonth kernel rejects every sub-second part with the requested name, so the message would be accurate. One of those two query error cases would then be enough.

Comment on lines 573 to +576
let secs = date_part(array, DatePart::Second)?;
// This assumes array is primitive and not a dictionary
let secs = as_int32_array(secs.as_ref())?;
let subsecs = date_part(array, DatePart::Nanosecond)?;
let subsecs = as_int32_array(subsecs.as_ref())?;

// Special case where there are no nulls.
if subsecs.null_count() == 0 {
let r: Int64Array = binary(secs, subsecs, |secs, subsecs| {
(secs as i64) * 1_000_000_000 + (subsecs as i64)
})?;
Ok(Arc::new(r))
} else {
// Nulls in secs are preserved, nulls in subsecs are treated as zero to account for the case
// where the number of nanoseconds overflows.
let r: Int64Array = secs
.iter()
.zip(subsecs)
.map(|(secs, subsecs)| {
secs.map(|secs| {
let subsecs = subsecs.unwrap_or(0);
(secs as i64) * 1_000_000_000 + (subsecs as i64)
})
})
.collect();
Ok(Arc::new(r))
}
let fraction = date_part(array, part)?;

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.

For timestamps and times this makes three passes. Two date_part calls each run a chrono conversion per row, plus a timezone lookup per row and a timezone string parse per call when a timezone is set. Then binary allocates a third values buffer and a third bitmap for the null union. This matches the bench, where timestamps stay at about 1.1x while intervals and durations gain 3.6x to 41x.

timezone_part_typed above already has the one-pass shape. One unary_opt over as_datetime_with_timezone::<T> (or as_datetime::<T> without a timezone), computing dt.second() * PER_SECOND + dt.nanosecond() / (1_000_000_000 / PER_SECOND), would do one conversion per row and one allocation. main already used two passes, so a follow-up is fine. I have not measured it. The ns_tz case you added is where I'd expect it to show most.

/// `epoch` is NULL only for a NULL input, but the integer parts can be NULL
/// for a non-null input, so they are always nullable.
#[test]
fn return_field_nullability() {

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.

The integer-part cases here are already exercised end to end by the non-null reproducers at the end of the slt. The ones from #26685 fail on main with declared as non-nullable. The only new information is that epoch follows the input. Could this move to the slt with the existing DESCRIBE idiom (see describe.slt)? For example DESCRIBE SELECT extract(epoch from ts) AS e, extract(second from ts) AS s FROM (VALUES (timestamp '2020-01-01')) t(ts), once with and once without a NULL row. That shows the declared nullability directly.

Comment on lines +84 to 88
fn return_field_from_args(&self, _args: ReturnFieldArgs) -> Result<FieldRef> {
// Nullable like the integer parts of `date_part`, which this simplifies
// to, because they can be NULL for a non-null input
Ok(Arc::new(Field::new(self.name(), DataType::Int32, true)))
}

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.

With the input no longer read, this override now does exactly what the trait default does. ScalarUDFImpl::return_field_from_args builds Field::new(self.name(), self.return_type(..)?, true). So return_type could return Ok(DataType::Int32) and the override could go.

Another option is to delegate to datafusion_functions::datetime::date_part().return_field_from_args(args), which keeps the two matching by construction. That would also fix a mismatch this PR does not touch. nanosecond and epoch pass through simplify unchanged, but Spark declares Int32 while date_part returns Int64 and Float64.

Either way, the new test checks Int32 and nullable directly and then again against date_part. The comparison alone is enough. Since DESCRIBE shows the planned schema before simplification, it could also be a DESCRIBE SELECT date_part('SECOND', ts) ... query in spark/datetime/date_part.slt instead of a unit test.

Comment on lines +1265 to +1271
# Reproducer from https://github.com/apache/datafusion/issues/26678
query III
SELECT extract(nanosecond from arrow_cast(1500000000, 'Duration(Nanosecond)')),
extract(nanosecond from interval '1.5 seconds'),
extract(microsecond from interval '1.5 seconds')
----
1500000000 1500000000 1500000

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.

These repeat queries added above. Column 1 is L1424, and columns 2 and 3 are L1201-L1202. In the next reproducer, the first column is L1245. Could the issue links go on those queries instead?

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

Labels

functions Changes to functions implementation spark Changes to datafusion-spark crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

3 participants