Visualize data with Redash
Install Redash and start a running instance, following the Docker Based Developer Installation Guide.
Configure Redash to query Pinot, by doing the following:
Create visualizations, by doing the following:
Add pinot db dependency
Apache Pinot provides a Python client library pinotdb
to query Pinot from Python applications. Install pinotdb
inside the Redash worker instance to make network calls to Pinot.
Navigate to the root directory where you’ve cloned Redash. Run the following command to get the name of the Redash worker container (by default,
redash_worker_1
):
docker-compose ps
Run the following command (change
redash_worker_1
to your own Redash worker container name, if applicable):
Restart Docker.
Add Python data source for Pinot
In Redash, select Settings > Data Sources.
On the Redash Settings - Data Source page, add
Pinot
as the name of the data source, enterpinotdb
in the Modules to import prior to running the script field.Enter the following optional fields as needed:
AdditionalModulesPaths: Enter a comma-separated list of absolute paths on the Redash server to Python modules to make available when querying from Redash. Useful for private modules unavailable in
pip
.AdditionalBuiltins: Specify additional built-in functions as needed. By default, Redash automatically includes 25 Python built-in functions.
Click Save.
Start Pinot
Run the following command in a new terminal to spin up an Apache Pinot Docker container in the quick start mode with a baseball stats dataset built in.
Run a query in Redash
In Redash, select Queries > New Query, and then select the Python data source you created in Add a Python data source for Pinot.
Add Python code to query data. For more information, see the Python query runner.
Click Execute to run the query and view results.
You can also include libraries like Pandas to perform more advanced data manipulation on Pinot’s data and visualize the output with Redash.
For more information, see Querying in Redash documentation.
Example Python queries
Query top 10 teams by total runs
The following query connects to Pinot and queries the baseballStats
table to retrieve the top ten players with the highest scores. The results are transformed into a dictionary format supported by Redash.
Query top 10 teams by total runs
Query total strikeouts by year
Add a visualization and dashboard in Redash
Add a visualization
In Redash, after you've ran your query, click the New Visualization tab, and select the type of visualization your want to create, for example, Bar Chart. The Visualization Editor appears with your chart.
For example, you may want to create a bar chart to view the top 10 players with highest scores.
You may want to create a line chart to view the total variation in strikeouts over time.
For more information, see Visualizations.
Add a dashboard
Create a dashboard with one or more visualizations (widgets).
In Redash, go to Dashboards > New Dashboards.
Add the widgets to your dashboard. For example, by adding the three visualizations from the three example queries above, you create a Baseball stats dashboard.
For more information, see Dashboards in the Redash documentation.
Last updated