Pinot Version | 1.0.0 |
---|---|
Code | startreedata/pinot-recipes/geospatial-default |
Prerequisites
To follow the code examples in this guide, you must install Docker locally and download recipes.Navigate to recipe
- If you haven’t already, download recipes.
- In terminal, go to the recipe by running the following command:
Launch Pinot Cluster
Spin up a Pinot Cluster by running the following command:Generating Geospatial data
This recipe contains a data generator that produces JSON documents that contain Geospatial points but occassionally null values instead. You’ll need to first install the following dependencies:Kafka ingestion
We’re going to ingest this data into an Apache Kafka topic using the kcat command line tool. We’ll also usejq
to structure the data in the key:payload
structure that Kafka expects:
Pinot Schema and Table
Now let’s create a Pinot Schema and Table. First, the schema:point
has a data type of BYTES
. Geospatial columns must use the BYTES
type because Pinot will serialize the Geospatial objects into bytes for storage purposes.
We are also passing in a defaultNullValue
which must be a Hex encoded representation of a point. In this case the point is a location in the Arctic.
You can get back a Hex encoded representation of a Geospatial object by running a query that returns the object.
For example:
Query Results
003fe5f4a42008f90c4054e004d205fbe4 |
---|
003fe5f4a42008f90c4054e004d205fbe4 |
BYTES
column we’ll need to create the schema and table separately, rather than using the AddTable
command. If we try to use the AddTable
command, we’ll end up with double decoding of the defaultNullValue
, resulting in Pinot trying to store an invalid value.
Instead, we’ll create the schema with the AddSchema
command:
Querying for defaults
We can then the following query to check how many times the default value has been used:distance | count(*) |
---|---|
0 | 3147529 |
250.4421880885498 | 1 |
250.35032602023736 | 1 |
250.3445873086931 | 1 |
250.32023987252305 | 1 |
250.28500644222484 | 1 |
250.26623501229875 | 1 |
250.26271972684384 | 1 |
250.25918510024783 | 1 |
250.2511511361528 | 1 |