Skip to content

perf: precompile formats in to_time - #23964

Merged
neilconway merged 2 commits into
apache:mainfrom
lyne7-sc:perf/optimize-to-time
Jul 30, 2026
Merged

perf: precompile formats in to_time#23964
neilconway merged 2 commits into
apache:mainfrom
lyne7-sc:perf/optimize-to-time

Conversation

@lyne7-sc

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • Closes #.

Rationale for this change

to_time previously parsed the Chrono format strings for every non-null input value. For array inputs, this repeated the same format parsing for each row in a batch.

This PR precompiles the format strings once per udf invocation and reuses the compiled format items while parsing each value.

What changes are included in this PR?

  • Precompile and reuse the to_time format strings.
  • Add tests for multiple formats and NULL values.

Are these changes tested?

Yes. Existing tests pass, and new slt coverage was added for multiple formats and NULL values.

Are there any user-facing changes?

No. This is an internal performance optimization.

Benchmarks

group                      main                            optimize-to-time
-----                       ----------                             ----------------
to_time_10pct_nulls_100k    1.83      7.3±0.34ms        ? ?/sec    1.00      4.0±0.47ms        ? ?/sec
to_time_no_nulls_100k       1.82      7.9±0.33ms        ? ?/sec    1.00      4.4±0.42ms        ? ?/sec

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Jul 29, 2026
@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.84%. Comparing base (e8a65f2) to head (643ce49).
⚠️ Report is 42 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23964      +/-   ##
==========================================
+ Coverage   80.66%   80.84%   +0.17%     
==========================================
  Files        1095     1096       +1     
  Lines      372294   373848    +1554     
  Branches   372294   373848    +1554     
==========================================
+ Hits       300324   302247    +1923     
+ Misses      54055    53567     -488     
- Partials    17915    18034     +119     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Looks great, overall! Nicely targeted and well-written improvement, nice perf win.

Comment thread datafusion/sqllogictest/test_files/datetime/timestamps.slt
@neilconway
neilconway enabled auto-merge July 30, 2026 12:25
@lyne7-sc

Copy link
Copy Markdown
Contributor Author

Thanks for your review @neilconway!

@neilconway
neilconway added this pull request to the merge queue Jul 30, 2026
Merged via the queue into apache:main with commit 44aae94 Jul 30, 2026
37 checks passed
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants