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:
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=mypassword
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:
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
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
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
property must be set to
true in the
pre-aggregation definition. This is because Superset uses loose date ranges when
generating SQL queries.