Skip to content

Conversation

@zhiqiang-hhhh
Copy link
Contributor

cherry pick from #38608

…8608)

* Target

Fix unstable result of hist function when involving null value.

* Reproduce

test result of
`regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions2.groovy`
is unstable, sql `SELECT histogram(k7, 5) FROM baseall` will sometimes
acts like the second argument is not passed in.

* Root reason

We have short-circuit in AggregateFunctionNullVariadicInline, when this
row is NULL, the value will not be added by the nested function.
Implementation of histogram relies on its add method to get its seconds
argument, when we have an all null value block, histogram will not get
its seconds arg even if sql is like `select(k7, 5)`, so a max_bucket_num
with default value 128 is serialized. When we do merging, and happens to
deserialize the above block at last, the max_bucket_num in merge stage
will be assigned to 128, and this leads to the wrong result.

* Fix by

Init value of max_bucket_num is assigned to 0, when we do merging, we
will discard this aggregated data if its max_bucket_num is 0.
@zhiqiang-hhhh
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2024

clang-tidy review says "All clean, LGTM! 👍"

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.40% (9268/25459)
Line Coverage: 27.92% (75802/271490)
Region Coverage: 26.77% (38995/145649)
Branch Coverage: 23.50% (19789/84226)
Coverage Report: http://coverage.selectdb-in.cc/coverage/7a794a85680dd1794a83bb3fafa0de0576737721_7a794a85680dd1794a83bb3fafa0de0576737721/report/index.html

@yiguolei yiguolei merged commit c7b59b3 into apache:branch-2.1 Aug 6, 2024
@zhiqiang-hhhh zhiqiang-hhhh deleted the pick_38608_to_upstream_branch-2.1 branch August 6, 2024 03:08
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