Filtering records during ingestion
To learn how to filter records when ingesting data into Pinot, watch the following video, or complete the tutorial below.
Pinot Version | 1.0.0 |
---|---|
Code | startreedata/pinot-recipes/filtering |
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
You can spin up a Pinot Cluster by running the following command:
This command will run a single instance of the Pinot Controller, Pinot Server, Pinot Broker, and Zookeeper. You can find the docker-compose.yml file on GitHub.
Dataset
We’re going to import the following JSON file:
data/import.json
Pinot Schema and Table
Now let’s create a Pinot Schema and Table.
First, the schema:
config/schema.json
We’ll also have the following table config:
config/table.json
Our filtering function ensures that any records with a year
property with a value of 2010 or more are not imported.
You can create the table and schema by running the following command:`
You should see a message similar to the following if everything is working correctly:
Ingestion Job
Now we’re going to import the JSON file into Pinot. We’ll do this with the following ingestion spec:
The import job will map fields in each JSON document to a corresponding column in the movies
schema. If one of the fields doesn’t exist in the schema it will be skipped.
You can also apply transformation functions to JSON documents during the ingestion process. For more details, see the JSON Transformation Functions guide.
You can run the following command to run the import:
Querying
Once that’s completed, navigate to localhost:9000/#/query and click on the movies
table or copy/paste the following query:
You will see the following output:
genre | id | title | year |
---|---|---|---|
Comedy | 332567813147483648 | The Ugly Truth | 2009 |
Romance | 346905752147483649 | P.S. I Love You | 2007 |
Fantasy | 394030854147483651 | The Curious Case of Benjamin Button | 2008 |
Query Results