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

rewrite avg for algebraic optimization #20183

Merged
merged 1 commit into from
Feb 9, 2021

Conversation

ucasfl
Copy link
Collaborator

@ucasfl ucasfl commented Feb 7, 2021

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

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Perform algebraic optimizations of arithmetic expressions inside avg aggregate function. close #20092.

@robot-clickhouse robot-clickhouse added the pr-improvement Pull request with some product improvements label Feb 7, 2021
@alexey-milovidov
Copy link
Member

I have some doubts about the cases when result may change. Maybe add a separate option for it?

@ucasfl
Copy link
Collaborator Author

ucasfl commented Feb 8, 2021

I have some doubts about the cases when result may change. Maybe add a separate option for it?

There is already a setting optimize_arithmetic_operations_in_aggregate_functions, you mean add another setting for avg?

@alexey-milovidov
Copy link
Member

Yes, let's name it optimize_arithmetic_operations_in_aggregate_functions_avg.

@alexey-milovidov
Copy link
Member

Why I'm worried?

avg(x / 2) does not overflow right now but may start to overflow when optimization is enabled.
It is still Ok to enable it by default but we need a separate setting.

@ucasfl
Copy link
Collaborator Author

ucasfl commented Feb 9, 2021

Why I'm worried?

avg(x / 2) does not overflow right now but may start to overflow when optimization is enabled.
It is still Ok to enable it by default but we need a separate setting.

But I think sum(x / 2) also has the problem.

@alexey-milovidov
Copy link
Member

Ok, reasonable. Let's merge as is.

@alexey-milovidov alexey-milovidov self-assigned this Feb 9, 2021
@alexey-milovidov alexey-milovidov merged commit faf28ee into ClickHouse:master Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-improvement Pull request with some product improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Perform algebraic optimizations of arithmetic expressions inside aggregate functions.
3 participants