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
Fix a bug with projections and the aggregate_functions_null_for_empty
setting
#42198
Conversation
@@ -176,6 +176,11 @@ QueryPlanPtr MergeTreeDataSelectExecutor::read( | |||
"No projection is used when allow_experimental_projection_optimization = 1 and force_optimize_projection = 1", | |||
ErrorCodes::PROJECTION_NOT_USED); | |||
|
|||
if (settings.force_optimize_projection && settings.aggregate_functions_null_for_empty) |
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 part looks useless.
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 useless?
I treat it this way: if a user requested "force_optimize_projection" it should know if the optimization is not applied.
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.
if a user requested "force_optimize_projection" it should know if the optimization is not applied.
The exception thrown a few lines above carries such meaning exactly.
If there is some projection define in the table, and for any reason (like aggregate_functions_null_for_empty = true
) it cannot be used, the exception will be thrown.
The setting was to mimic the behavior of force_primary_key
, which has the description: Throw an exception if there is primary key in a table, and it is not used.
. However, I just did a quick test and found that it will throw even when table doesn't have primary key. Not sure whether we should change the description or the behavior.
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.
However, I just did a quick test and found that it will throw even when table doesn't have primary key. Not sure whether we should change the description or the behavior.
Better to change the behavior. (Don't throw if no primary key)
LGTM. |
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.
LGTM
…e_functions_null_for_empty` setting
…e_functions_null_for_empty` setting
…e_functions_null_for_empty` setting
…e_functions_null_for_empty` setting
Backport #42198 to 22.9: Fix a bug with projections and the `aggregate_functions_null_for_empty` setting
Backport #42198 to 22.8: Fix a bug with projections and the `aggregate_functions_null_for_empty` setting
Backport #42198 to 22.7: Fix a bug with projections and the `aggregate_functions_null_for_empty` setting
Backport #42198 to 22.3: Fix a bug with projections and the `aggregate_functions_null_for_empty` setting
Fix a bug with projections and the `aggregate_functions_null_for_empty` setting
…quest !58) bugfix-cherry-pick Merge pull request ClickHouse#42198 from ClickHouse/fix-projections ClickHouse#42499 ClickHouse#42342 ClickHouse#42384 ClickHouse#42198
setting (for query_plan_optimize_projection) Fix a bug with projections and the aggregate_functions_null_for_empty setting. This was already fixed in PR ClickHouse#42198 but got forgotten after using query_plan_optimize_projection.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix a bug with projections and the
aggregate_functions_null_for_empty
setting. This bug is very rare and appears only if you enable theaggregate_functions_null_for_empty
setting in the server's config. This closes #41647.