Skip to content

branch-4.1: [fix](be) Fix nth_value for upper bounded windows #64864#64896

Merged
yiguolei merged 1 commit into
branch-4.1from
auto-pick-64864-branch-4.1
Jun 26, 2026
Merged

branch-4.1: [fix](be) Fix nth_value for upper bounded windows #64864#64896
yiguolei merged 1 commit into
branch-4.1from
auto-pick-64864-branch-4.1

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Cherry-picked from #64864

### What problem does this PR solve?

Related PR: #50559

Problem Summary: nth_value over an upper-bounded/lower-unbounded window
frame such as ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING is
normalized by reversing the order and frame, then evaluating nth_value
with a negative offset over a cumulative frame. The BE nth_value window
state replaced the tracked frame row count on each range update, so
later rows in the cumulative frame could address the wrong row or return
NULL. The fix keeps the cumulative frame row count across range updates,
and FE preserves literal offset typing when negating bigint nth_value
arguments. This adds BE unit coverage for the reversed cumulative
execution path and a regression case comparing nth_value to lead for the
original SQL frame.

### Release note

Fix nth_value results for ROWS BETWEEN CURRENT ROW AND UNBOUNDED
FOLLOWING window frames.
@github-actions github-actions Bot requested a review from yiguolei as a code owner June 26, 2026 09:51
@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

FE UT Coverage Report

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

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 100.00% (5/5) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 54.56% (20808/38138)
Line Coverage 38.09% (198576/521371)
Region Coverage 34.57% (155936/451105)
Branch Coverage 35.53% (67996/191364)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (5/5) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 58.30% (21720/37255)
Line Coverage 41.55% (215568/518826)
Region Coverage 38.26% (173772/454172)
Branch Coverage 39.00% (74750/191647)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 31.58% (6/19) 🎉
Increment coverage report
Complete coverage report

@yiguolei yiguolei merged commit bfeb1d8 into branch-4.1 Jun 26, 2026
29 of 32 checks passed
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.

3 participants