Skip to content

branch-4.1: [fix](timestamptz) Preserve correct DST fold branch to go cross the transition point #63034#63091

Open
github-actions[bot] wants to merge 2 commits intobranch-4.1from
auto-pick-63034-branch-4.1
Open

branch-4.1: [fix](timestamptz) Preserve correct DST fold branch to go cross the transition point #63034#63091
github-actions[bot] wants to merge 2 commits intobranch-4.1from
auto-pick-63034-branch-4.1

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 8, 2026

Cherry-picked from #63034

…ransition point (#63034)

Problem Summary: TIMESTAMPTZ values in a DST fold hour could be
converted through an ambiguous local time, making explicit post-fold
instants use the earlier branch during FE literal handling and BE
floor/ceil/date_trunc execution.

The old code would treat DST repeated hours like `2024-11-03 01:xx` as
local civil time without offset when parsing TIMESTAMPTZ with explicit
offset in FE, and when BE converts local time to UTC using
date_trunc/floor/ceil, it would lose the `-04/-05` offset branch
information and default to the earlier branch. After the fix, FE
directly constructs TimestampTzLiteral from timezone-aware strings, and
BE uses the original UTC instant's offset to select pre/post branches
when converting repeated hours back to UTC, thus preserving the correct
fold branch.

when `time_zone = 'America/New_York'`:
```sql
SELECT
CAST(CAST('2024-11-03 01:05:00 -05:00' AS TIMESTAMPTZ(6)) AS VARCHAR(64)) AS ts,
CAST(date_trunc(CAST('2024-11-03 01:05:30 -05:00' AS TIMESTAMPTZ(6)), 'hour') AS VARCHAR(64)) AS hour_trunc;
```

before:
```
ts                                      hour_trunc
2024-11-03 01:05:00.000000-04:00       2024-11-03 01:00:00.000000-04:00
```

now:
```
ts                                      hour_trunc
2024-11-03 01:05:00.000000-05:00       2024-11-03 01:00:00.000000-05:00
```
@github-actions github-actions Bot requested a review from yiguolei as a code owner May 8, 2026 12:49
@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hello-stephen
Copy link
Copy Markdown
Contributor

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 97.44% (38/39) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.49% (26365/36880)
Line Coverage 54.54% (279716/512837)
Region Coverage 51.81% (232386/448533)
Branch Coverage 53.17% (100432/188892)

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 90.00% (18/20) 🎉
Increment coverage report
Complete coverage report

@zclllyybb
Copy link
Copy Markdown
Contributor

run buildall

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants