-
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
expression: Add warning info for exprs that can not be pushed to storage layer #22713
Changes from 7 commits
f6f885c
32f386a
316c83f
7e03fd5
29fdcec
3e441da
f9f6927
5f9e0da
fecfbf2
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 |
---|---|---|
|
@@ -1161,6 +1161,13 @@ func canScalarFuncPushDown(scalarFunc *ScalarFunction, pc PbConverter, storeType | |
|
||
// Check whether this function can be pushed. | ||
if !canFuncBePushed(scalarFunc, storeType) { | ||
if pc.sc.InExplainStmt { | ||
storageName := storeType.Name() | ||
if storeType == kv.UnSpecified { | ||
storageName = "storage layer" | ||
} | ||
pc.sc.AppendWarning(errors.New("Scalar function '" + scalarFunc.FuncName.L + "'(signature: " + scalarFunc.Function.PbCode().String() + ") can not be pushed to " + storageName)) | ||
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. Looks like each time only one function can be shown. For a real world case it will be tricky. 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. In TiDB implementation, for each 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 not reading the explain result to find which functions are not pushed down? |
||
} | ||
return false | ||
} | ||
|
||
|
@@ -1184,6 +1191,9 @@ func canScalarFuncPushDown(scalarFunc *ScalarFunction, pc PbConverter, storeType | |
|
||
func canExprPushDown(expr Expression, pc PbConverter, storeType kv.StoreType) bool { | ||
if storeType == kv.TiFlash && expr.GetType().Tp == mysql.TypeDuration { | ||
if pc.sc.InExplainStmt { | ||
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. duration and func() will rusult two warnings? if func() cannot be pushed down 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. If the |
||
pc.sc.AppendWarning(errors.New("Expr '" + expr.String() + "' can not be pushed to TiFlash because it contains Duration type")) | ||
} | ||
return false | ||
} | ||
switch x := expr.(type) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ package core | |
import ( | ||
"math" | ||
|
||
"github.com/pingcap/errors" | ||
"github.com/pingcap/parser/ast" | ||
"github.com/pingcap/parser/charset" | ||
"github.com/pingcap/parser/mysql" | ||
|
@@ -1114,6 +1115,13 @@ func CheckAggCanPushCop(sctx sessionctx.Context, aggFuncs []*aggregation.AggFunc | |
return false | ||
} | ||
if !aggregation.CheckAggPushDown(aggFunc, storeType) { | ||
if sc.InExplainStmt { | ||
storageName := storeType.Name() | ||
if storeType == kv.UnSpecified { | ||
storageName = "storage layer" | ||
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. when will we encounter this branch? 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. In |
||
} | ||
sc.AppendWarning(errors.New("Agg function '" + aggFunc.Name + "' can not be pushed to " + storageName)) | ||
} | ||
return false | ||
} | ||
if !expression.CanExprsPushDown(sc, aggFunc.Args, client, storeType) { | ||
|
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.
for example: select fun1(), agg_fun2() from t where func3() group by c having fun4(); if funx() cannot be pushed down, will this shows 4 warnings, even though it first encounters func3()?
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 pr only record the unsupported functions, it does not change the behavior of optimizer, so if
func3
is not supported, and the optimizer decide not pushdownagg
to the storage layer, then onlyfunc3
will be recorded.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.
other unsupported functions also will be recorded?