Skip to main content
Pinot can transform data at ingestion. In this recipe, we’ll learn how to use a transformation to change the name of a column. We will ingest a CSV file with a column containing spaces in its name. We will then use a transformation function to remove the space while the data is being ingested into Pinot.

Prerequisites

To follow the code examples in this guide, you must install Docker locally and download recipes.
  1. If you haven’t already, download recipes.
  2. In the terminal, navigate to this recipe’s directory:

Launch Pinot Cluster

Launch a Pinot Cluster:
This command will run a single instance of the Pinot Controller, Pinot Server, Pinot Broker, and Zookeeper. You can find and examine the docker-compose.yml file on GitHub.

Dataset

We’re going to import the following CSV file, in which the Case Number column heading contains a space: data/import.csv

Pinot Schema and Table

Next we create a Pinot Schema and Table. A common pattern when creating a schema is to create columns that map directly to the names of the fields in our data source. We can’t do that in this case since column names can’t contain spaces, so instead we’ll use the following:
config/schema.json We’ll also have the following table config:
config/table.json
The entry under ingestionConfig.transformConfigs makes sure that data in the Case Number field in the data source is ingested into the CaseNumber column of the table. To learn more about writing these functions, see the ingestion transformation documentation.
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

Next, we import the CSV file into Pinot. We’ll do this with the following ingestion spec:
config/job-spec.yml Run the following command to run the import:

Querying

Once that’s completed, navigate to localhost:9000/#/query and click on the crimes table or copy/paste the following query:
You will see the following output: Query Results