Skip to content

Move-away "uniqCombined" as a separate aggregated function#3406

Merged
alexey-milovidov merged 20 commits intoClickHouse:masterfrom
abyss7:3958/many_templates
Nov 22, 2018
Merged

Move-away "uniqCombined" as a separate aggregated function#3406
alexey-milovidov merged 20 commits intoClickHouse:masterfrom
abyss7:3958/many_templates

Conversation

@abyss7
Copy link
Copy Markdown
Contributor

@abyss7 abyss7 commented Oct 17, 2018

Accepts single param - the HLL precision.

AggregateFunctionPtr createAggregateFunctionUniqCombined(
const std::string & name, const DataTypes & argument_types, const Array & params)
{
UInt8 precision = 17; /// default value - must correlate with default ctor of |AggregateFunctionUniqCombinedData|
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If it MUST be correlated it's better to set named constant and use it both here and in ctor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It correlates with a hardcoded union member initialization, the constant won't help - so I left the comment. The code now looks like: AggregateFunctionUniqCombinedDataWithKey() : set_17() {} - Also I can use a macro-definition as constant, if it's better.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My point is there should be only one place there magic number 17 set.

SELECT Y, uniqCombined(X) FROM (SELECT number AS X, (3*X*X - 7*X + 11) % 37 AS Y FROM system.numbers LIMIT 15) GROUP BY Y;
SELECT Y, uniqCombined(X) FROM (SELECT number AS X, (3*X*X - 7*X + 11) % 37 AS Y FROM system.numbers LIMIT 3000) GROUP BY Y;
SELECT Y, uniqCombined(X) FROM (SELECT number AS X, (3*X*X - 7*X + 11) % 37 AS Y FROM system.numbers LIMIT 1000000) GROUP BY Y;
SELECT Y, uniqCombined(15)(X) FROM (SELECT number AS X, (3*X*X - 7*X + 11) % 37 AS Y FROM system.numbers LIMIT 15) GROUP BY Y;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it change default behavior? What if someone already use uniqCombined without parameter. Would he (or she :) ) get the same values after update?

Comment thread dbms/src/AggregateFunctions/AggregateFunctionUniqCombined.h Outdated
Comment thread dbms/src/AggregateFunctions/AggregateFunctionUniqCombined.h
@alexey-milovidov alexey-milovidov merged commit 89e3c5c into ClickHouse:master Nov 22, 2018
alexey-milovidov added a commit that referenced this pull request Nov 22, 2018
alexey-milovidov added a commit that referenced this pull request Nov 23, 2018
@alexey-milovidov
Copy link
Copy Markdown
Member

https://gist.github.com/alexey-milovidov/9cbbc2916f8d946594049d424487e458

Now the uniqHLL12 function can be considered obsolete.

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.

4 participants