Superset
Apache Superset (opens in a new tab) is a popular open-source data exploration and visualization platform. Preset (opens in a new tab) is a fully-managed service for Superset.
Semantic Layer Sync
It is recommended to use Semantic Layer Sync to connect Cube to Superset or Preset. It automatically synchronizes the data model between Cube and Superset or Preset.
SQL API
You can also use the SQL API to connect Cube to Superset or Preset.
Semantic Layer Sync is the recommended way to connect Superset or Preset to Cube. If you're using the SQL API, consider migrating to Semantic Layer Sync.
Here's a short video guide:
Cube Cloud
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:
Self-hosted Cube
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=mypassword
Connecting from Superset
Apache Superset connects to Cube as to a Postgres database.
In Apache Superset, go to Data > Databases, then click + Database to add a new database:
Querying data
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: time
Using 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.
Additional Configuration
Pre-Aggregations
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.