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.


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:

Apache Superset: databases page

Your cubes will be exposed as tables, where both your measures and dimensions are columns.

Let's use the following Cube data schema:

cube(`Orders`, {
  sql: `SELECT * FROM public.orders`,

  measures: {
    count: {
      type: `count`,

  dimensions: {
    status: {
      sql: `status`,
      type: `string`,

    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:

Apache Superset: SQL Editor page with successful query

Now, we can explore this dataset. Let's create a new chart of type line with Orders dataset.

Apache Superset: SQL Editor page with successful query

We can select the COUNT(*) as a metric and createdAt 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 schema file.

To allow queries from Superset to match pre-aggregations in Cube, the allowNonStrictDateRangeMatch 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?