-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Multi Table Delete Support: join with reference table #14784
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
ac40cae
to
a183f1f
Compare
…ent and binder to bind target to tableID Signed-off-by: Harshit Gangal <harshit@planetscale.com>
a183f1f
to
a337b58
Compare
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
eb6b779
to
b664f43
Compare
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
9af89a8
to
39bcd53
Compare
…ete logic Signed-off-by: Harshit Gangal <harshit@planetscale.com>
39bcd53
to
2da13e9
Compare
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
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.
Rest looks good to me
dmlOp operators.Operator, | ||
hints *queryHints, | ||
) (logicalPlan, error) { | ||
func buildDeleteLogicalPlan(ctx *plancontext.PlanningContext, rb *operators.Route, dmlOp operators.Operator, stmt *sqlparser.Delete, hints *queryHints) (logicalPlan, error) { |
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.
Why are we adding stmt
to the function call, if we already have the ast in del.AST
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.
Never mind, I found the answer looking at the code further, you removed the AST from the delete operator
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.
nit: we can put the arguments on multiple lines as it was before
func buildDelete(op *Delete, qb *queryBuilder) { | ||
buildQuery(op.Source, qb) | ||
qb.dmlOperator = op | ||
|
||
sel, ok := qb.stmt.(*sqlparser.Select) | ||
if !ok { | ||
panic(vterrors.VT13001("expected a select here")) | ||
} |
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.
It would be nice to have a comment explaining why the Delete's source has to result in a select query in the buildQuery call. I understand why, but it took me a while too. Having a comment would be nice for future reference.
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
if len(node.Targets) > 1 { | ||
return false | ||
} | ||
if len(node.TableExprs) != 1 { | ||
return 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.
nit: you can move these two conditions into a single if
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.
will make the change in the next PR.
multiShardErr := vterrors.VT12001("multi-shard or vindex write statement") | ||
if len(del.TableExprs) != 1 { | ||
return multiShardErr | ||
} | ||
_, isAliasedExpr := del.TableExprs[0].(*sqlparser.AliasedTableExpr) | ||
if !isAliasedExpr { | ||
return multiShardErr | ||
} | ||
|
||
// Delete is only supported for single Target. |
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.
Can there be no target at all?
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.
there there is no nothing to delete. So, one target is a must.
Signed-off-by: Harshit Gangal <harshit@planetscale.com> Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
…able (#4007) * cherry pick of 14784 Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> * fix: build on delete operator (#14833) Signed-off-by: Harshit Gangal <harshit@planetscale.com> --------- Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Signed-off-by: Harshit Gangal <harshit@planetscale.com> Co-authored-by: Harshit Gangal <harshit@planetscale.com>
Description
This PR is an initial PR towards supporting
multi table delete
. This PR adds support for single target delete with table references with sharded and reference table.Related Issue(s)
Checklist