githubEdit

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 quickstart 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 quickstart.

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 legacy PQL (Pinot Query Language) queries, which have been deprecated since Pinot 0.7.1. Use the SQL API and ResultTable instead.

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:

Last updated

Was this helpful?