Golang

Pinot Client for Golang

Pinot provides a native Go clientarrow-up-right to query the database directly from Go application.

Install

  1. Follow this Pinot quickstartarrow-up-right link to install and start Pinot locally.

bin/quick-start-batch.sh
git clone [email protected]:startreedata/pinot-client-go.git
cd pinot-client-go
  1. Build and run the example application to query from the Pinot batch quickstartarrow-up-right.

go build ./examples/batch-quickstart
./batch-quickstart

Use the Golang client

Create a Pinot connection

Initialize the Pinot client using one of the methods below.

Zookeeper Path

pinotClient := pinot.NewFromZookeeper([]string{"localhost:2123"}, "", "QuickStartCluster")

List of broker addresses

ClientConfig

The Go client repository contains an examplearrow-up-right script.

Note: You need not configure “content-type” as a header in ExtraHTTPHeader.

ClientConfig with HTTP client

If you require a specialized HTTP client, you have the option to create your own HTTP client and utilize the NewWithConfigAndClient function to establish a Pinot client that can accommodate a custom HTTP client.

The Go client repository contains an examplearrow-up-right script.

Query Pinot

The Go client repository contains an examplearrow-up-right script.

Code snippet:

Response format

The query response has the following format:

Note that AggregationResults and SelectionResults are holders for Pinot query language (PQL) queries.

Meanwhile, ResultTable is the holder for SQL queries. ResultTable is defined as:

RespSchema is defined as:

There are multiple functions defined for ResultTable, such as the following:

See an example of a function in use herearrow-up-right and below:

Was this helpful?