Skip to content

branch-4.1: [fix](be) Return NaN for avg_weighted when sum of weights is zero #64333 - #64431

Merged
yiguolei merged 1 commit into
branch-4.1from
auto-pick-64333-branch-4.1
Jun 15, 2026
Merged

branch-4.1: [fix](be) Return NaN for avg_weighted when sum of weights is zero #64333#64431
yiguolei merged 1 commit into
branch-4.1from
auto-pick-64333-branch-4.1

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Cherry-picked from #64333

…4333)
Problem Summary: When the sum of weights passed to avg_weighted is zero
but the weighted data sum is non-zero, the function computed data_sum /
weight_sum and returned +/-Infinity (e.g. avg_weighted(f1, f2) over rows
(1, 1), (2, -1) returned -Infinity). The expected mathematical result of
a division by zero weight is undefined, so it should return NaN.
This fixes AggregateFunctionAvgWeightedData::get() to return quiet_NaN()
when weight_sum is exactly zero, instead of producing Infinity.
@github-actions
github-actionsBot requested a review from yiguolei as a code ownerJune 11, 2026 12:24
@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 UT Coverage Report

Increment line coverage 0.00% (0/6) 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage53.85% (20388/37861)
Line Coverage37.43% (193374/516607)
Region Coverage33.83% (150817/445785)
Branch Coverage34.83% (66022/189568)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (6/6) 🎉

Increment coverage report
Complete coverage report

CategoryCoverage
Function Coverage73.56% (27238/37030)
Line Coverage57.20% (294416/514689)
Region Coverage54.82% (246521/449685)
Branch Coverage56.27% (106942/190055)

@yiguolei

Copy link
Copy Markdown
Contributor

skip buildall

@github-actions

Copy link
Copy Markdown
ContributorAuthor

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

@github-actionsgithub-actionsBot added approved Indicates a PR has been approved by one committer. reviewed labels Jun 15, 2026
@github-actions

Copy link
Copy Markdown
ContributorAuthor

PR approved by anyone and no changes requested.

@yiguoleiyiguolei reopened this Jun 15, 2026
@yiguolei
yiguolei merged commit 10e0c29 into branch-4.1Jun 15, 2026
32 of 34 checks passed
@morningman
morningman deleted the auto-pick-64333-branch-4.1 branch July 8, 2026 14:10
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@hello-stephen@yiguolei@jacktengg