Skip to content

Conversation

@TCeason
Copy link
Collaborator

@TCeason TCeason commented Nov 21, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

  • Introduce a timezone lookup-table crate and refactor datetime parsing (cursor_read_datetime_ext.rs) plus arithmetic helpers (date_helper. rs, timestamp scalars) to call into it, covering both UTC→local decomposition and local→UTC
    resolution across DST gaps.
  • Update format parsing to cope with jiff 0.2.16 (string_to_format_datetime), reject conflicting %s directives, and leverage the fast path for to_date, add_months, age, etc., while keeping a jiff fallback for out-of-range years.
  • Refresh SQL logic suites and the new datetime_fast_path bench so CI can validate DST edge cases and developers can track the observed speed-ups locally.

Benchmarks

  • Command: cargo bench -p databend-common-functions --bench bench -- datetime_fast_path
  • Results (branch vs upstream main):
  • date_add_days: 214.4 µs vs 211 µs (noise-level change)
  • string_parse_to_date: 42.16 ms vs 44.43 ms (~5% faster)
  • timestamp_add_months: 14.34 ms vs 19.78 ms (~1.4× faster)
  • timestamp_extract_components: 12.48 ms vs 20.19 ms (~1.6× faster)

In PR:

cargo bench -p databend-common-functions --bench bench -- datetime_fast_path
    Finished `bench` profile [optimized + debuginfo] target(s) in 0.41s
     Running benches/bench.rs (target/release/deps/bench-dcd523671a1b5430)
Timer precision: 11 ns
bench                               fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ datetime_fast_path                             │               │               │               │         │
   ├─ date_add_days                 193.5 µs      │ 353.8 µs      │ 210 µs        │ 214.4 µs      │ 100     │ 100
   ├─ string_parse_to_date          40.03 ms      │ 62.7 ms       │ 40.06 ms      │ 42.16 ms      │ 12      │ 12
   ├─ timestamp_add_months          14.3 ms       │ 14.59 ms      │ 14.33 ms      │ 14.34 ms      │ 35      │ 35
   ╰─ timestamp_extract_components  12.43 ms      │ 12.53 ms      │ 12.47 ms      │ 12.48 ms      │ 41      │ 41

In Main:

cargo bench -p databend-common-functions --bench bench -- datetime_fast_path
    Finished `bench` profile [optimized + debuginfo] target(s) in 0.42s
     Running benches/bench.rs (target/release/deps/bench-caf5866ff0e5233c)
Timer precision: 10 ns
bench                               fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ datetime_fast_path                             │               │               │               │         │
   ├─ date_add_days                 193.7 µs      │ 318 µs        │ 210.1 µs      │ 211 µs        │ 100     │ 100
   ├─ string_parse_to_date          44.34 ms      │ 44.63 ms      │ 44.43 ms      │ 44.43 ms      │ 12      │ 12
   ├─ timestamp_add_months          19.7 ms       │ 19.87 ms      │ 19.78 ms      │ 19.78 ms      │ 26      │ 26
   ╰─ timestamp_extract_components  20.16 ms      │ 20.22 ms      │ 20.19 ms      │ 20.19 ms      │ 25      │ 25

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@TCeason TCeason marked this pull request as draft November 21, 2025 05:13
@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Nov 21, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@TCeason TCeason force-pushed the fix_timezone branch 7 times, most recently from 28edf2f to 05c127b Compare November 25, 2025 04:49
@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

🤖 CI Job Analysis

Workflow: 19668172742

📊 Summary

  • Total Jobs: 83
  • Failed Jobs: 1
  • Retryable: 0
  • Code Issues: 1

NO RETRY NEEDED

All failures appear to be code/test issues requiring manual fixes.

🔍 Job Details

  • linux / test_compat_client_cluster: Not retryable (Code/Test)

🤖 About

Automated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed).

@TCeason TCeason marked this pull request as ready for review November 25, 2025 10:44
- add the databend-common-timezone crate and bump jiff to 0.2.16 so the workspace shares a single LUT-backed converter
- use the new helpers inside IO parsing, expression utilities, timestamp scalars, and age() to preserve offsets/DST behaviour even for pre-1970 dates
- expand SQLLogic/unit coverage plus add a datetime_fast_path bench
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-refactor this PR changes the code base without new features or bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant