-
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
plan: support ?
in Order By / Group By / Limit Offset clauses
#8206
Conversation
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
@dbjoa Would you file another PR to make this |
@zz-jason Yes, I would. |
@iamxy Could you help us with this?
|
Hi, @dbjoa Here I add some instructions on how to update parser for TiDB: You can follow that. |
/run-all-tests |
@eurekaka |
@dbjoa the log indicates it is the newly added case that fails:
|
/run-all-tests |
2 similar comments
/run-all-tests |
/run-all-tests |
order by ?
performs correctly when prepare-cache is enabled
@dbjoa Could you update |
@zz-jason I've updated the PR to use the latest parser. |
/run-all-tests |
1 similar comment
/run-all-tests |
/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
order by ?
performs correctly when prepare-cache is enabledOrder By ?
| Group By ?
| Limit ? Offset ?
Order By ?
| Group By ?
| Limit ? Offset ?
ParamMarkerExpr
in Order By / Group By / Limit Offset clauses
ParamMarkerExpr
in Order By / Group By / Limit Offset clauses?
in Order By / Group By / Limit Offset clauses
expression/util.go
Outdated
} | ||
value, err := GetParamExpression(ctx, v.P.(*driver.ParamMarkerExpr)) | ||
if err != nil { | ||
return 0, true, errors.Trace(err) |
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.
Once it's traced, we don't need to trace it anymore.
So here we can just return err.
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.
Thank you for your detailed comments. The updated PR will address the issue.
/run-all-tests |
/run-integration-ddl-test |
expression/util.go
Outdated
@@ -526,3 +527,55 @@ func GetParamExpression(ctx sessionctx.Context, v *driver.ParamMarkerExpr, useCa | |||
} | |||
return value, nil | |||
} | |||
|
|||
// ConvertToByItemExpr rewrites ByItem.ExprNode to a proper ExprNode. | |||
func ConvertToByItemExpr(n ast.Node) ast.Node { |
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.
how about:
func ConstructPositionExpr(v *driver.ParamMarkerExpr) *ast.PositionExpr {
return &ast.PositionExpr{P: v}
}
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.
In order to do that, we must add the checking logic of driver.ParamMarkerExpr
typed node before calling ConstructPositionExpr
. Hence, IMHO, the current impl. might be simpler than your suggestions.
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.
[jianzhang.zj:~/opt/gopath/src/github.com/pingcap/tidb] git:(cloud-pi/fix-the-issue-8153 ✔)
➜ ag -w ConvertToByItemExpr
planner/core/logical_plan_builder.go
827: newNode := expression.ConvertToByItemExpr(inNode)
1207: newNode := expression.ConvertToByItemExpr(inNode)
expression/util.go
531:// ConvertToByItemExpr rewrites ByItem.ExprNode to a proper ExprNode.
532:func ConvertToByItemExpr(n ast.Node) ast.Node {
These are all the appearance of ConvertToByItemExpr
, and as you can see in the function caller, the input parameter is guaranteed to be driver.ParamMarkerExpr
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.
Got it!
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
What problem does this PR solve?
Fix #8153
What is changed and how it works?
parser.ByItem
to supportast.ParamMarkerExpr
OrderByClause
orGroupByClause
aren't cachedCheck List
Tests
Code changes
parser
)Side effects
Related changes
parser
repository (i.e., the parser PR #27)This change is