Skip to content

[fix](function) preserve sign for negative sub-hour TIMESTAMPTZ offsets#62823

Open
Mryange wants to merge 1 commit intoapache:masterfrom
Mryange:fix-sign-negative-sub-hour
Open

[fix](function) preserve sign for negative sub-hour TIMESTAMPTZ offsets#62823
Mryange wants to merge 1 commit intoapache:masterfrom
Mryange:fix-sign-negative-sub-hour

Conversation

@Mryange
Copy link
Copy Markdown
Contributor

@Mryange Mryange commented Apr 24, 2026

What problem does this PR solve?

Problem Summary:

When BE renders TIMESTAMPTZ values, it derives the timezone sign from the truncated hour component.
For negative sub-hour offsets such as -00:30, integer division makes the hour component 0, so the
renderer emits +00:30 instead of -00:30.

This affects both constant-folded expressions and runtime values rendered from table data.

Root cause:

  • Old logic:
int offset_hours = time_offset / 3600;
int offset_mins = (std::abs(time_offset) % 3600) / 60;
char sign = offset_hours >= 0 ? '+' : '-';
  • For time_offset = -1800, offset_hours becomes 0, so the sign is rendered as +.

Fix:

  • Determine the sign from the original second offset.
  • Split hour and minute fields from the absolute offset value.
  • Add a focused UT for -00:30 rendering.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented Apr 24, 2026

run buildall

@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?

@Mryange Mryange marked this pull request as ready for review April 24, 2026 11:35
@hello-stephen
Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 100.00% (8/8) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.33% (20401/38255)
Line Coverage 36.87% (192169/521249)
Region Coverage 33.19% (149521/450450)
Branch Coverage 34.30% (65399/190648)

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (8/8) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.53% (26818/37494)
Line Coverage 53.87% (280023/519860)
Region Coverage 47.26% (215474/455963)
Branch Coverage 50.55% (97504/192877)

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