diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index 54022570c44..d64172ea047 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -1161,6 +1161,15 @@ func (e *Executor) handleOther(ctx context.Context, safeSession *SafeSession, sq } switch dest.(type) { + case key.DestinationKeyspaceID: + rss, err := e.resolver.resolver.ResolveDestination(ctx, destKeyspace, destTabletType, dest) + if err != nil { + return nil, err + } + if len(rss) != 1 { + return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "Unexpected error, DestinationKeyspaceID mapping to multiple shards: %s, got: %v", sql, dest) + } + destKeyspace, dest = rss[0].Target.Keyspace, key.DestinationShard(rss[0].Target.Shard) case key.DestinationShard: // noop default: diff --git a/go/vt/vtgate/executor_test.go b/go/vt/vtgate/executor_test.go index 485ba84f471..94846076e43 100644 --- a/go/vt/vtgate/executor_test.go +++ b/go/vt/vtgate/executor_test.go @@ -1102,6 +1102,22 @@ func TestExecutorOther(t *testing.T) { SbcLookupCnt: 0, }, }, + { + targetStr: "TestExecutor/-20", + wantCnts: cnts{ + Sbc1Cnt: 1, + Sbc2Cnt: 0, + SbcLookupCnt: 0, + }, + }, + { + targetStr: "TestExecutor[00]", + wantCnts: cnts{ + Sbc1Cnt: 1, + Sbc2Cnt: 0, + SbcLookupCnt: 0, + }, + }, } stmts := []string{