Pinot Version | 0.9.3 |
---|---|
Code | startreedata/pinot-recipes/backfill |
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, run the following command to navigate to the recipe:
Launch Pinot Cluster
You can spin up a Pinot Cluster by running the following command:Pinot Schema and Tables
Now let’s create a Pinot Schema, as well as real-time and offline tables. Pinot is going to take care of populating data into the offline table, but it still expects us to configure the table.Schema
Our schema is going to capture some order events, and looks like this:Real-Time Table
And the real-time table is defined below:The
realtime.segment.flush.threshold.rows
config is intentionally set to an extremely small value so that the segment will be committed after 5 records have been ingested.
In a production system this value should be set much higher, as described in the configuring segment threshold guide.Offline Table
The offline table config is defined below:Ingesting Data
Let’s ingest data into theevents
Kafka topic, by running the following:

Scheduling the RT2OFF Job
The Real-Time to Offline Job can be scheduled automatically via the real-time table config or manually via the REST API. We can trigger it manually by running the following command:
Viewing offline segment
You can list all the segments for a table by making the following request to the HTTP API:orders_1632463351000_1632467070000_0
. You can check which records it contains by running the following query:

Replacing offline segment
Let’s now backfill those 7 records to increase the value in the amount column by 20%. The documents with the updated amount value are indata/orders.json
, shown below:
orders_1632463351000_1632467070000_0
:
orders
table:
amount
column for the first 7 orders has been updated:
$segmentName | amount | customer_id | order_id | order_status | ts |
---|---|---|---|---|---|
orders_1632463351000_1632467070000_0 | 15.948 | 101 | 1 | OPEN | 1632463351000 |
orders_1632463351000_1632467070000_0 | 251.22 | 102 | 2 | IN_TRANSIT | 1632463361000 |
orders_1632463351000_1632467070000_0 | 239.22 | 103 | 3 | COMPLETED | 1632463391000 |
orders_1632463351000_1632467070000_0 | 3.888 | 105 | 4 | COMPLETED | 1632467065000 |
orders_1632463351000_1632467070000_0 | 11.724 | 103 | 5 | OPEN | 1632467066000 |
orders_1632463351000_1632467070000_0 | 66.624 | 104 | 6 | OPEN | 1632467068000 |
orders_1632463351000_1632467070000_0 | 63.048 | 104 | 7 | CANCELLED | 1632467070000 |
orders__0__1__20230321T1038Z | 13.29 | 105 | 8 | OPEN | 1632667070000 |
orders__0__1__20230321T1038Z | 2.92 | 105 | 9 | IN_TRANSIT | 1632667170000 |
orders__0__1__20230321T1038Z | 12.22 | 105 | 10 | COMPLETED | 1632677270000 |
orders__0__2__20230321T1038Z | 13.94 | 106 | 11 | OPEN | 1632677270400 |
orders__0__2__20230321T1038Z | 20.32 | 107 | 12 | OPEN | 1632677270403 |
orders__0__2__20230321T1038Z | 45.11 | 108 | 13 | OPEN | 1632677270508 |
orders__0__2__20230321T1038Z | 129.22 | 109 | 14 | OPEN | 1632677270699 |