Skip to content

fix(query): use jiff to_zoned for naive datetime timezone resolution - #19647

Merged
KKould merged 1 commit into
databendlabs:mainfrom
TCeason:fix-ts-tz
Mar 31, 2026
Merged

fix(query): use jiff to_zoned for naive datetime timezone resolution#19647
KKould merged 1 commit into
databendlabs:mainfrom
TCeason:fix-ts-tz

Conversation

@TCeason

@TCeason TCeason commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

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

Summary

string_to_timestamp_tz used a "fake UTC" approach to resolve timezone
offset for naive datetime inputs: it treated the naive datetime as UTC,
then looked up the timezone offset at that (wrong) UTC instant. This
produced incorrect results when the fake and real UTC instants straddled
a DST transition.

For example, '2024-11-03 05:30:00' in America/New_York should resolve
to EST (-0500), giving real UTC 10:30. But the old code treated 05:30
as UTC to look up the offset, and since 05:30 UTC is before the 06:00
UTC transition, it got EDT (-0400) instead of EST (-0500).

Fix: replace the manual fake-UTC-then-lookup with jiff's
DateTime::to_zoned(), which correctly interprets a naive datetime in
the target timezone and handles DST disambiguation natively.

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

@github-actions github-actions Bot added the pr-bugfix this PR patches a bug in codebase label Mar 31, 2026
@TCeason
TCeason requested a review from KKould March 31, 2026 10:07
@KKould
KKould merged commit 7533fdc into databendlabs:main Mar 31, 2026
90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix this PR patches a bug in codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants