-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
expression, cmd: fix ColumnSubstitute and allow some cases to substitute #38826
Changes from 2 commits
1841e8b
33215d4
db51040
5c80ad7
dce94b0
2b04bdb
24450ce
2df07ee
d4aaac1
a53fff7
6884ed4
28f15f3
c81372c
5482443
674b0e8
369c980
7b757b6
74913d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -426,7 +426,6 @@ func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression | |
if v.InOperand { | ||
newExpr = SetExprColumnInOperand(newExpr) | ||
} | ||
newExpr.SetCoercibility(v.Coercibility()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why remove this, rest is ok for me There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may not be substituted in L424. If keep it, a test in constant propagation will fail. |
||
return true, false, newExpr | ||
case *ScalarFunction: | ||
substituted := false | ||
|
@@ -463,7 +462,12 @@ func ColumnSubstituteImpl(expr Expression, schema *Schema, newExprs []Expression | |
_ = append(append(append(tmpArgs, refExprArr.Result()[0:idx]...), refExprArr.Result()[idx+1:]...), newFuncExpr) | ||
_, newColl := DeriveCollationFromExprs(v.GetCtx(), append(v.GetArgs(), newFuncExpr)...) | ||
if coll == newColl { | ||
changed = checkCollationStrictness(coll, newFuncExpr.GetType().GetCollate()) | ||
if newFuncExpr.GetType().GetCollate() == arg.GetType().GetCollate() && newFuncExpr.Coercibility() == arg.Coercibility() { | ||
// It's safe to use the new expression, otherwise some cases in projection push-down will be wrong. | ||
changed = true | ||
} else { | ||
changed = checkCollationStrictness(coll, newFuncExpr.GetType().GetCollate()) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why must make the substitute happen, I thought it was just an optimization, at least it should not get the wrong result if the optimization does not take effect. /cc @winoros |
||
} | ||
} | ||
} | ||
|
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.
The change is correct the NOT IN's key name not in('guo') is put in other cond. And the inner filter
exam.stu_id = stu.id
is put at the join key.