The java client can be found in pinot-clients/pinot-java-client. Here's an example of how to use the pinot-java-client
to query Pinot.
Connections to Pinot are created using the ConnectionFactory
class’ utility methods to create connections to a Pinot cluster given a Zookeeper URL, a Java Properties object or a list of broker addresses to connect to.
Queries can be sent directly to the Pinot cluster using the Connection.execute(org.apache.pinot.client.Request)
and Connection.executeAsync(org.apache.pinot.client.Request)
methods of Connection:
Queries can also use a PreparedStatement
to escape query parameters:
Results can be obtained with the various get methods in the first ResultSet, obtained through the getResultSet(int)
method:
Note
The examples for the sections below this note, are for querying the PQL endpoint, which is deprecated and will be deleted soon. For more information about the 2 endpoints, visit Querying Pinot.
If queryFormat pql
is used in the Request
, there are some differences in how the results can be accessed, depending on the query.
In the case of aggregation, each aggregation function is within its own ResultSet. A query with multiple aggregation function will return one result set per aggregation function, as they are computed in parallel.
In case of aggregation group by, there will be as many ResultSets as the number of aggregations, each of which will contain multiple results grouped by a group key.
Pinot Client for Golang
Applications can use this golang client library to query Apache Pinot.
Source Code Repo: https://github.com/fx19880617/pinot-client-go
Please follow this Pinot Quickstart link to install and start Pinot batch QuickStart locally.
Check out Client library Github Repo
Build and run the example application to query from Pinot Batch Quickstart
Pinot client could be initialized through:
Please see this example for your reference.
Code snippet:
Query Response is defined as the struct of following:
Note that AggregationResults
and SelectionResults
are holders for 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
, like:
Sample Usage is here