Connecting to Superset/Preset
You can connect a Cube project to Apache Superset using the Cube SQL API. Apache Superset is an open-source data exploration and visualization platform, commonly used to visualize business metrics and performance.
Here's a short video guide on how to connect Apache Superset to Cube.
Don't have a Cube project yet? Learn how to get started here.
Click How to connect your BI tool link on the Overview page, navigate to the SQL API tab and enable it. Once enabled, you should see the screen like the one below with your connection credentials:
You need to set the following environment variables to enable the Cube SQL API. These credentials will be required to connect to Cube from Superset later.
CUBEJS_PG_SQL_PORT=5432
CUBEJS_SQL_USER=myusername
CUBEJS_SQL_PASSWORD=mypasswordApache Superset connects to Cube as to a Postgres database.
In Apache Superset, go to Data > Databases, then click + Database to add a new database:
Your cubes will be exposed as tables, where both your measures and dimensions are columns.
Let's use the following Cube data model:
cubes:
- name: orders
sql_table: orders
measures:
- name: count
type: count
dimensions:
- name: status
sql: status
type: string
- name: created
sql: created_at
type: timeUsing the SQL API, orders will be exposed as a table. In Superset, we can
create datasets based on tables. Let's create one from orders table:
Now, we can explore this dataset. Let's create a new chart of type line with "Orders" dataset.
We can select the COUNT(*) as a metric and created_at as the time column with
a time grain of month.
The COUNT(*) aggregate function is being mapped to a measure of type
count in Cube's
Orders data model file.
To allow queries from Superset to match pre-aggregations in Cube, the
allow_non_strict_date_range_match property
must be set to true in the pre-aggregation definition. This is because
Superset uses loose date ranges when generating SQL queries.
Did you find this page useful?