-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLICKHOUSE-3723 Multiply aggregate states. Fix and optimize #2527. #3034
Conversation
if (m % 2) | ||
{ | ||
for (size_t i = 0; i < input_rows_count; ++i) | ||
function->merge(vec_to[i], vec_from[i], arena.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arena will get out of scope, because it is not attached to ColumnAggregateFunction.
Need to add a test for functions that really use arena during merge.
else | ||
{ | ||
for (size_t i = 0; i < input_rows_count; ++i) | ||
function->merge(vec_from[i], vec_from[i], arena.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we modifying source column? It's not permitted.
(It should not even be able to compile, but actually you get AggregateDataPtr instead of ConstAggregateDataPtr from const ColumnAggregateFunction.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add a test that contain both source and multiplied states.
SELECT sumMerge(y) AS z FROM ( SELECT sumState(x) * 11 AS y FROM ( SELECT 1 AS x UNION ALL SELECT 2 AS x)); | ||
SELECT countMerge(x) AS y FROM ( SELECT 2 * countState() AS x FROM ( SELECT 1 )); | ||
SELECT countMerge(x) AS y FROM ( SELECT 0 * countState() AS x FROM ( SELECT 1 UNION ALL SELECT 2)); | ||
SELECT sumMerge(y) AS z FROM ( SELECT 3 * sumState(x) * 2 AS y FROM ( SELECT 1 AS x UNION ALL SELECT 2 AS x)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add tests for groupArray, uniq, groupUniqArray and something very unusual up to your choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot about something unusual.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en