Skip to content

[fix](functions)Preserve TIMESTAMPTZ in LEAD/LAG by adding TimeStampTzType signature matching#62779

Merged
starocean999 merged 1 commit intoapache:masterfrom
starocean999:master_0424
May 6, 2026
Merged

[fix](functions)Preserve TIMESTAMPTZ in LEAD/LAG by adding TimeStampTzType signature matching#62779
starocean999 merged 1 commit intoapache:masterfrom
starocean999:master_0424

Conversation

@starocean999
Copy link
Copy Markdown
Contributor

Problem: When LEAD/LAG use ExplicitlyCastableSignature, Nereids could fail to find a TIMESTAMPTZ signature and fall back to coercion to DateTimeV2Type, causing an injected cast like cast(ts_tz as DATETIMEV2(6)) and losing the timezone suffix.

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

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

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

@starocean999
Copy link
Copy Markdown
Contributor Author

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

No blocking issues found in this PR.

Checkpoint review:

  • Goal / correctness: The change fixes Nereids LEAD/LAG signature selection for TIMESTAMPTZ by adding TimeStampTzType.WILDCARD to RequireTrivialTypes, so Lead/Lag no longer need to fall back to a DATETIMEV2 signature on this path. The added unit test covers signature resolution for both functions.
  • Scope / minimality: The patch is small and focused: one signature-list update plus a targeted FE test.
  • Concurrency: Not involved; this is static FE type-resolution code with no new shared mutable state or locking.
  • Lifecycle / initialization: No special lifecycle concerns beyond the existing static signature initialization in Lead/Lag; the new type follows the same pattern.
  • Config / compatibility: No new config, protocol, persistence, or storage compatibility impact.
  • Parallel code paths: Both LEAD and LAG are updated consistently. I did not find another FE signature table for these functions outside the Nereids builtin registry.
  • Test coverage: The new FE unit test checks TIMESTAMPTZ signature matching for both LEAD and LAG. I could not run it locally in this runner because thirdparty/installed/bin/protoc is missing, so runtime verification is blocked by environment setup rather than by the patch itself.
  • Observability / transactions / writes / FE-BE variables: Not applicable here.
  • Performance: No concern; this only adds one extra candidate type to a tiny static signature list.
  • Other issues: No blocking findings. Minor note only: the comment in RequireTrivialTypes still says the list is equal to Type.trivialTypes, but Type.trivialTypes does not currently include TIMESTAMPTZ.

User focus points:

  • No additional user-provided review focus was supplied.

@starocean999
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 100% (0/0) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.00% (0/219) 🎉
Increment coverage report
Complete coverage report

@starocean999
Copy link
Copy Markdown
Contributor Author

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

No blocking issues found in this PR.\n\nCheckpoint review:\n- Goal / correctness: The change fixes Nereids LEAD/LAG signature selection for TIMESTAMPTZ by adding TimeStampTzType.WILDCARD to RequireTrivialTypes, so these functions can preserve TIMESTAMPTZ instead of falling back to DATETIMEV2 on this path. The added unit test covers signature resolution for both functions.\n- Scope / minimality: The patch is small and focused: one signature-list update plus a targeted FE unit test.\n- Concurrency: Not involved; this is FE type-resolution/signature code with no new shared mutable runtime state or locking.\n- Lifecycle / initialization: No special lifecycle concerns beyond existing static signature initialization in Lead/Lag; the new wildcard follows the existing DateTimeV2/TimeV2 pattern.\n- Config / compatibility: No new config, protocol, persistence, storage format, or rolling-upgrade compatibility impact.\n- Parallel code paths: LEAD and LAG are updated consistently. Related window functions using retArgType/AnyDataType already preserve argument type through a different path.\n- Tests: The new FE unit test checks TIMESTAMPTZ matching for both LEAD and LAG. I attempted to run ./run-fe-ut.sh --run org.apache.doris.nereids.trees.expressions.functions.window.TimestampTzLeadLagSignatureTest locally, but generated-source.sh failed because thirdparty/installed/bin/protoc is missing in this runner checkout; remote PR status shows FE UT success.\n- Observability / transactions / writes / FE-BE variables: Not applicable.\n- Performance: No concern; this adds one candidate type to a small static signature list.\n- Other issues: No blocking findings. Minor non-blocking note: the RequireTrivialTypes comment says the list is equal to Type.trivialTypes, but Type.trivialTypes does not currently include TIMESTAMPTZ.\n\nUser focus points:\n- No additional user-provided review focus was supplied.

@starocean999 starocean999 marked this pull request as ready for review May 6, 2026 08:00
@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

PR approved by anyone and no changes requested.

@starocean999 starocean999 merged commit 48da948 into apache:master May 6, 2026
36 checks passed
github-actions Bot pushed a commit that referenced this pull request May 6, 2026
…zType signature matching (#62779)

Problem: When LEAD/LAG use ExplicitlyCastableSignature, Nereids could
fail to find a TIMESTAMPTZ signature and fall back to coercion to
DateTimeV2Type, causing an injected cast like cast(ts_tz as
DATETIMEV2(6)) and losing the timezone suffix.
github-actions Bot pushed a commit that referenced this pull request May 6, 2026
…zType signature matching (#62779)

Problem: When LEAD/LAG use ExplicitlyCastableSignature, Nereids could
fail to find a TIMESTAMPTZ signature and fall back to coercion to
DateTimeV2Type, causing an injected cast like cast(ts_tz as
DATETIMEV2(6)) and losing the timezone suffix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.0.x dev/4.1.x reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants