New analyzer: add eliminate min/max/any/anyLast aggregators pass#52230
New analyzer: add eliminate min/max/any/anyLast aggregators pass#52230novikd merged 24 commits intoClickHouse:masterfrom
Conversation
|
This is an automated comment for commit cadaa7b with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page Successful checks
|
87c7f8a to
4d4625f
Compare
tests/queries/0_stateless/02496_remove_redundant_sorting_analyzer.reference
Outdated
Show resolved
Hide resolved
13f7167 to
6260887
Compare
|
Hi @novikd, please review the PR when you have a changce. |
4c63eed to
d06f22a
Compare
novikd
left a comment
There was a problem hiding this comment.
In general LGTM, but I think we should get rid of KeepEliminateFunctionVisitor.
|
@JackyWoo thank you for the contribution! I'm sorry that it took so long for me to review this PR. If you don't have time to finish it now, I can do it myself. |
…s_of_group_by_keys
|
Thanks I will handle it soon |
|
I decided to reimplement this optimization a bit, I'll push my changes to this PR. It requires more attention. For example, the following query works wrong with the current implementation: SELECT min(number) OVER (PARTITION BY number % 2)
FROM numbers(3)
GROUP BY number |
| @@ -0,0 +1,39 @@ | |||
| set allow_experimental_analyzer = 1; | |||
There was a problem hiding this comment.
The test requires comments, which will be shown in the reference file as well. So, it'd be much easier to find a query and corresponding output in reference file (and wise versa)
| manager.addPass(std::make_unique<RewriteArrayExistsToHasPass>()); | ||
| manager.addPass(std::make_unique<NormalizeCountVariantsPass>()); | ||
|
|
||
| /// should before AggregateFunctionsArithmericOperationsPass |
There was a problem hiding this comment.
If it should be applied/not applied depends on the optimize_aggregators_of_group_by_keys setting
There was a problem hiding this comment.
It is checked here
ClickHouse/src/Analyzer/Passes/AggregateFunctionOfGroupByKeysPass.cpp
Lines 35 to 36 in cadaa7b
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Eliminates min/max/any/anyLast aggregators of GROUP BY keys in SELECT section.
Example: SELECT max(column) FROM table GROUP BY column;
Result: SELECT column FROM table GROUP BY column;