-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Normalize AggregateFunction types and state representations #39420
Normalize AggregateFunction types and state representations #39420
Conversation
if (typeid(rhs) != typeid(*this)) | ||
return false; | ||
|
||
/// All count(*) variants are of the same type. |
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.
This is not the best solution for this problem.
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 will send a proposal how to do it better.
It should use #25015 and #24820, see Please also fix the following cases:
|
5304ba5
to
b0cbb9f
Compare
I think all cases are resolved now. |
b0cbb9f
to
0e77179
Compare
Some tests don't work anymore. Turn into draft until they are all fixed. |
9a807e2
to
1dee71a
Compare
Not related to this PR, but triggers by this PR's test. A minimal reproducible case :
Not related to this PR. All other cases are green. It's ready for review. |
1dee71a
to
5bf609e
Compare
I cannot figure out a proper fix yet, only a working draft #39618 Added another case of aggregate state normalization: This PR is complete but might be blocked by some existing issue due to new fuzz test. I'm not sure if it's proper to land now. |
94a0b66
to
99f8092
Compare
@@ -0,0 +1,7 @@ | |||
-- Tags: no-s3-storage |
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.
But there is no projection, so "no-s3-storage" tag and "projection" from the name can be removed.
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.
There is minmax_count_projection
which is used. I'll remove "no-s3-storage" tag as this projection works with s3 storage.
99f8092
to
26acb37
Compare
@@ -73,13 +73,19 @@ class IAggregateFunction : public std::enable_shared_from_this<IAggregateFunctio | |||
/// Get the data type of internal state. By default it is AggregateFunction(name(params), argument_types...). | |||
virtual DataTypePtr getStateType() const; | |||
|
|||
/// Same as the above but normalize state types so that variants with the same binary representation will use the same type. |
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.
Why do we need non-normalized State Type?
I thought, that if the states are the same, they should use the same type.
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.
Because getStateType()
is used to do correct finalization of aggregate states.
-- If we return original state type for quantiles*
SELECT finalizeAggregation(quantilesTimingState(0.5)(number)) FROM numbers(10)
┌─finalizeAggregation(quantilesTimingState(0.5)(number))─┐
│ [5] │
└────────────────────────────────────────────────────────┘
-- If we return normalized state type for quantiles*, which param is always 1
SELECT finalizeAggregation(quantilesTimingState(0.5)(number)) FROM numbers(10)
┌─finalizeAggregation(quantilesTimingState(0.5)(number))─┐
│ [9] │
└────────────────────────────────────────────────────────┘
It's because of this
Other test failures if we only use normalized state types: https://s3.amazonaws.com/clickhouse-test-reports/39420/69347028c54edcedc9a43e6795c52c15ad6972ec/fast_test.html
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.
Ok, understood. Let's keep it with two separate functions.
b4783a7
to
52fcf00
Compare
52fcf00
to
5580209
Compare
…ize_aggregateFunction_types_and_state_representations test for Decimal aggregateFunction normalization ClickHouse#39420
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Normalize
AggregateFunction
types and state representations because optimizations like #35788 will treatcount(not null columns)
ascount()
, which might confuses distributed interpreters with the following error :Conversion from AggregateFunction(count) to AggregateFunction(count, Int64) is not supported
.