-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
planner: do not eliminate group_concat in aggregate elimination #9967
Conversation
/run-all-tests |
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
@@ -36,6 +36,19 @@ type aggregationEliminateChecker struct { | |||
// For count(expr), sum(expr), avg(expr), count(distinct expr, [expr...]) we may need to rewrite the expr. Details are shown below. | |||
// If we can eliminate agg successful, we return a projection. Else we return a nil pointer. | |||
func (a *aggregationEliminateChecker) tryToEliminateAggregation(agg *LogicalAggregation) *LogicalProjection { | |||
for _, af := range agg.AggFuncs { | |||
// TODO: Actually, we can rewrite GROUP_CONCAT. | |||
// When it accepts only 1 argument, we can extract this argument into a |
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 case is easy to be added in this pr?
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.
Noop, since group_concat_max_len is configurable.
We can not ensure whether the length of the final result exceeds max_len even if there is only 1 argument.
And, maybe it'll be easier to implement if we wrap the argument(s) into a concat_ws despite the count of the arguments.
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #9967 +/- ##
================================================
+ Coverage 77.4704% 77.4772% +0.0067%
================================================
Files 403 404 +1
Lines 81777 81775 -2
================================================
+ Hits 63353 63357 +4
+ Misses 13707 13704 -3
+ Partials 4717 4714 -3 |
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
/run-unit-test |
What problem does this PR solve?
fix #9922
What is changed and how it works?
Do not eliminate group_concat considering system variable group_concat_max_len.
Actually, we can rewrite GROUP_CONCAT when all the arguments it
accepts are promised to be NOT-NULL. (Recorded as a task in #9968)
When it accepts only 1 argument, we can extract this argument into a
projection.
When it accepts multiple arguments, we can wrap the arguments with a
function CONCAT_WS and extract this function into a projection.
BUT, GROUP_CONCAT should truncate the final result according to the
system variable
group_concat_max_len
. To ensure the correctness ofthe result, we close the elimination of GROUP_CONCAT here.
Check List
Tests
Code changes
Side effects
Performance may regress when group_concat accepts only 1 argument.
Related changes