Pinot Client for Golang
Pinot provides a native Go client to query database directly from go application.
Follow this Pinot quickstart link to install and start Pinot locally.
Check out the client library GitHub repository.
Build and run the example application to query from the Pinot batch quickstart.
Initialize the Pinot client using one of the methods below.
The Go client repository contains an example script.
Code snippet:
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 here and below:
A lot of times the user wants to query data from an external application instead of using the built-in query explorer. Pinot provides external query client for this purpose. All of the clients have pretty standard interfaces so that the learning curve is minimum.
Currently Pinot provides the following clients
Applications can use this python client library to query Apache Pinot.
Pypi Repo: https://pypi.org/project/pinotdb/
Source Code Repo: https://github.com/python-pinot-dbapi/pinot-dbapi
Note:
pinotdb version >= 0.3.2 uses the Pinot SQL API (added in Pinot >= 0.3.0) and drops support for PQL API. So this client requires Pinot server version >= 0.3.0 in order to access Pinot.
pinotdb version in 0.2.x uses the Pinot PQL API, which works with pinot version <= 0.3.0, but may miss some new SQL query features added in newer Pinot version.
The db engine connection string is formated like this: pinot://:?controller=://:/
Run below command to start Pinot Batch Quickstart in docker and expose Pinot controller port 9000 and Pinot broker port 8000.
Once pinot batch quickstart is up, you can run the sample code snippet to query Pinot:
Sample Output:
Using parameters:
Run the command below to start Pinot Hybrid Quickstart in docker and expose Pinot controller port 9000 and Pinot broker port 8000.
Below is an example to query against Pinot Quickstart Hybrid:
Pinot offers standard JDBC interface to query the database. This makes it easier to integrate Pinot with other applications such as Tableau.
You can include the JDBC dependency in your code as follows -
You can also compile the JDBC code into a JAR and place the JAR in the Drivers directory of your application.
There is no need to register the driver manually as it will automatically register itself at the startup of the application.
Here's an example of how to use the pinot-jdbc-client
for querying. The client only requires the controller URL.
You can also use PreparedStatements. The placeholder parameters are represented using ?
** (question mark) symbol.
Pinot supports basic HTTP authorization, which can be enabled for your cluster using configuration. To support basic HTTP authorization in your client-side JDBC applications, make sure you are using Pinot JDBC 0.10.0+ or building from the latest Pinot snapshot. The following code snippet shows you how to connect to and query a Pinot cluster that has basic HTTP authorization enabled when using the JDBC client.