Skip to content
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

Merged
merged 6 commits into from
Sep 6, 2018
Merged

CLICKHOUSE-3723 Multiply aggregate states. Fix and optimize #2527. #3034

merged 6 commits into from
Sep 6, 2018

Conversation

CurtizJ
Copy link
Member

@CurtizJ CurtizJ commented Sep 4, 2018

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

@CurtizJ CurtizJ changed the title CLICKHOUSE-3723 Multiply aggregate state. Fix and optimize #2527. CLICKHOUSE-3723 Multiply aggregate states. Fix and optimize #2527. Sep 4, 2018
if (m % 2)
{
for (size_t i = 0; i < input_rows_count; ++i)
function->merge(vec_to[i], vec_from[i], arena.get());
Copy link
Member

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());
Copy link
Member

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.)

Copy link
Member

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));
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

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

.

@alexey-milovidov alexey-milovidov merged commit f77cd99 into ClickHouse:master Sep 6, 2018
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.

2 participants