From 2b98ef5edb634237f616a18a9f63647782f4769f Mon Sep 17 00:00:00 2001 From: Travis Date: Fri, 17 Apr 2020 14:46:13 -0500 Subject: [PATCH] add QueryUnary to the grpc client api --- api/client/grpc.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/client/grpc.go b/api/client/grpc.go index 7f65f2222..649faacec 100644 --- a/api/client/grpc.go +++ b/api/client/grpc.go @@ -156,6 +156,22 @@ func (c *GRPCClient) Query(ctx context.Context, index string, pql string) (pb.St return stream, err } +// QueryUnary returns a TableResponse for the given index and PQL string. +func (c *GRPCClient) QueryUnary(ctx context.Context, index string, pql string) (*pb.TableResponse, error) { + conn := c.Conn() + + if conn == nil { + return nil, errors.New("client has not established a grpc connection") + } + + grpcClient := pb.NewPilosaClient(conn) + + return grpcClient.QueryPQLUnary(ctx, &pb.QueryPQLRequest{ + Index: index, + Pql: pql, + }) +} + // Inspect returns a stream of RowResponse for the given index, columns, and filters. // It is intended to mimic something like "select [fields] from table where recordID IN (...)". func (c *GRPCClient) Inspect(ctx context.Context, index string, columnIDs []uint64, columnKeys []string, fieldFilters []string, limit, offset uint64) (pb.StreamClient, error) {