-
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
Improve sharded query routing for tuple list #14892
Improve sharded query routing for tuple list #14892
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
|
30f96b6
to
6af8ec1
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #14892 +/- ##
==========================================
- Coverage 47.29% 47.28% -0.02%
==========================================
Files 1137 1138 +1
Lines 238684 238787 +103
==========================================
+ Hits 112895 112912 +17
- Misses 117168 117257 +89
+ Partials 8621 8618 -3 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
3074bf8
to
825ce76
Compare
Signed-off-by: Harshit Gangal <[email protected]>
} | ||
|
||
if bvar.Type != sqltypes.Tuple { | ||
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "query argument '%s' must be a tuple (is %s)", bv.Key, bvar.Type) |
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.
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "query argument '%s' must be a tuple (is %s)", bv.Key, bvar.Type) | |
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "query argument '%s' must be a tuple (is %s)", bv.Key, bvar.Type.String()) |
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 can add that explicitly. Otherwise, It is not required when a String()
method is implemented.
} | ||
|
||
func (bv *TupleBindVariable) compile(c *compiler) (ctype, error) { | ||
return ctype{}, c.unsupported(bv) |
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 we add the logic for this here? We need this also for the type resolving as well, since we depend on compile for resolving types now as well. See for example also here:
vitess/go/vt/vtgate/evalengine/translate.go
Lines 697 to 703 in c534201
func (u *UntypedExpr) Compile(env *ExpressionEnv) (*CompiledExpr, error) { | |
typed, err := u.loadTypedExpression(env) | |
if err != nil { | |
return nil, err | |
} | |
return typed.compile(u.ir, u.collation, u.collationEnv, env.sqlmode) | |
} |
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 is a Tuple
type bind variable and I am not sure how to compile such.
I checked expr_bvar
and it is not recognized there
func (bvar *BindVariable) compile(c *compiler) (ctype, error) {
.
.
.
switch tt := typ.Type; {
.
.
default:
return ctype{}, vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "Type is not supported: %s", tt)
}
.
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.
We store something like
(1, 'a'), (2, 'b'), (3, 'c')... in a single bind variable.
and TupleBindVariable will provide single tuple for an index.
If Index is 1
then it returns
('a'), ('b'), ('c'). The output type is still a tuple.
Signed-off-by: Harshit Gangal <[email protected]>
Description
This PR improved the plan when filter condition has
List Argument
.E.g.
select 1 from user where (id, col) in ::vals
Earlier this query was send down as
Scatter
to all shards.With this PR, the query will send down to the shards based on where the sharding key (here
id
) routes this query.These
List Arguments
is currently used in DML routing for multi-table query and foreign key cascades.Old Plan:
New Plan:
Related Issue(s)
Checklist
Deployment Notes