Beispiel #1
0
// SplitQuery is part of the queryservice.QueryServer interface
func (q *query) SplitQuery(ctx context.Context, request *querypb.SplitQueryRequest) (response *querypb.SplitQueryResponse, err error) {
	defer q.server.HandlePanic(&err)
	ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
		request.EffectiveCallerId,
		request.ImmediateCallerId,
	)

	bq, err := querytypes.Proto3ToBoundQuery(request.Query)
	if err != nil {
		return nil, vterrors.ToGRPCError(err)
	}
	splits := []querytypes.QuerySplit{}
	splits, err = queryservice.CallCorrectSplitQuery(
		q.server,
		request.UseSplitQueryV2,
		ctx,
		request.Target,
		bq.Sql,
		bq.BindVariables,
		request.SplitColumn,
		request.SplitCount,
		request.NumRowsPerQueryPart,
		request.Algorithm)
	if err != nil {
		return nil, vterrors.ToGRPCError(err)
	}
	qs, err := querytypes.QuerySplitsToProto3(splits)
	if err != nil {
		return nil, vterrors.ToGRPCError(err)
	}
	return &querypb.SplitQueryResponse{Queries: qs}, nil
}
Beispiel #2
0
// SplitQuery is part of the queryservice.QueryServer interface
func (q *query) SplitQuery(ctx context.Context, request *querypb.SplitQueryRequest) (response *querypb.SplitQueryResponse, err error) {
	defer q.server.HandlePanic(&err)
	ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
		request.EffectiveCallerId,
		request.ImmediateCallerId,
	)
	bq, err := querytypes.Proto3ToBoundQuery(request.Query)
	if err != nil {
		return nil, tabletserver.ToGRPCError(err)
	}
	splits, err := q.server.SplitQuery(ctx, request.Target, bq.Sql, bq.BindVariables, request.SplitColumn, request.SplitCount, request.SessionId)
	if err != nil {
		return nil, tabletserver.ToGRPCError(err)
	}
	qs, err := querytypes.QuerySplitsToProto3(splits)
	if err != nil {
		return nil, tabletserver.ToGRPCError(err)
	}
	return &querypb.SplitQueryResponse{Queries: qs}, nil
}