Skip to content

[Bug](distinct) Fixes off-by-one error in aggregation limit check#60828

Open
BiteTheDDDDt wants to merge 2 commits intoapache:masterfrom
BiteTheDDDDt:fix_0225
Open

[Bug](distinct) Fixes off-by-one error in aggregation limit check#60828
BiteTheDDDDt wants to merge 2 commits intoapache:masterfrom
BiteTheDDDDt:fix_0225

Conversation

@BiteTheDDDDt
Copy link
Contributor

What problem does this PR solve?

Updates limit condition to ensure exactly the specified number of rows are returned. Prevents exceeding the row limit when the aggregated block reaches or equals the threshold.

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

Updates limit condition to ensure exactly the specified number of rows are returned.
Prevents exceeding the row limit when the aggregated block reaches or equals the threshold.
Copilot AI review requested due to automatic review settings February 25, 2026 08:22
@hello-stephen
Copy link
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?

@BiteTheDDDDt
Copy link
Contributor Author

run buildall

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an off-by-one condition in distinct streaming aggregation to ensure the operator does not emit more than the configured row limit.

Changes:

  • Adjusts the limit reach condition from > to >= when evaluating num_rows_returned + aggregated_block->rows()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 100.00% (1/1) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.52% (19584/37291)
Line Coverage 36.12% (182580/505481)
Region Coverage 32.46% (141686/436531)
Branch Coverage 33.41% (61415/183806)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (1/1) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 63.14% (23063/36524)
Line Coverage 46.37% (233720/503981)
Region Coverage 43.44% (191425/440699)
Branch Coverage 44.57% (82183/184392)

1 similar comment
@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (1/1) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 63.14% (23063/36524)
Line Coverage 46.37% (233720/503981)
Region Coverage 43.44% (191425/440699)
Branch Coverage 44.57% (82183/184392)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (1/1) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 63.27% (23107/36524)
Line Coverage 46.52% (234460/503981)
Region Coverage 43.59% (192093/440699)
Branch Coverage 44.76% (82531/184392)

@yiguolei yiguolei added the usercase Important user case type label label Feb 26, 2026
HappenLee
HappenLee previously approved these changes Feb 26, 2026
Copy link
Contributor

@HappenLee HappenLee left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Feb 26, 2026
@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@BiteTheDDDDt
Copy link
Contributor Author

run buildall

@github-actions github-actions bot removed the approved Indicates a PR has been approved by one committer. label Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev/4.0.x dev/4.1.x reviewed usercase Important user case type label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants