-
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: fix wrong behavior for != any() #20058
Conversation
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
planner/core/expression_rewriter.go
Outdated
@@ -650,15 +652,15 @@ func (er *expressionRewriter) handleNEAny(lexpr, rexpr expression.Expression, np | |||
return | |||
} | |||
plan4Agg := LogicalAggregation{ | |||
AggFuncs: []*aggregation.AggFuncDesc{firstRowFunc, countFunc}, | |||
AggFuncs: []*aggregation.AggFuncDesc{maxFunc, countFunc}, | |||
}.Init(er.sctx, er.b.getSelectOffset()) | |||
if hint := er.b.TableHints(); hint != nil { | |||
plan4Agg.aggHints = hint.aggHints | |||
} | |||
plan4Agg.SetChildren(np) | |||
firstRowResultCol := &expression.Column{ |
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.
Change this variable name as well?
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.
firstRowFunc, err := aggregation.NewAggFuncDesc(er.sctx, ast.AggFuncFirstRow, []expression.Expression{rexpr}, false) | ||
// If there is NULL in s.id column, s.id should be the value that isn't null in condition t.id != s.id. | ||
// So use function max to filter NULL. | ||
maxFunc, err := aggregation.NewAggFuncDesc(er.sctx, ast.AggFuncMax, []expression.Expression{rexpr}, false) |
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.
Max
would produce null
result when the s.id
is empty, would this impact the correctness of the result?
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 think firstrow also produces null
result when the s.id
is 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.
LGTM
/run-all-tests |
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-3.0 in PR #20061 |
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-4.0 in PR #20062 |
What problem does this PR solve?
Issue Number: close #20007
Problem Summary:
The result is unstable.
What is changed and how it works?
Proposal: xxx
What's Changed: Use max function instead of first_row function.
How it Works:
Related changes
Check List
Tests
Side effects
Release note