# Superset

## Start Superset with Docker Image

Start running [Superset Image](https://hub.docker.com/repository/docker/apachepinot/pinot-superset) with pre-built Superset Pinot connector.

{% tabs %}
{% tab title="Docker" %}
1\. Run below command to start a standalone Superset deployment

```
docker run \
  --network pinot-demo \
  --name=superset \
  -p 8088:8088 \
  -d apachepinot/pinot-superset:latest
```

2.1. (First time) Set up Admin account by running below command and follow instructions to set password.

```
docker exec -it superset superset fab create-admin \
               --username admin \
               --firstname Superset \
               --lastname Admin \
               --email admin@superset.com \
               --password admin
```

2.2. (First time) DB upgrade and Initialize Superset

```
docker exec -it superset superset db upgrade
docker exec -it superset superset init
```

3\. Import Pre-defined Pinot Datasources and Dashboard

```
docker exec \
    -t superset \
    bash -c 'superset import_datasources -p /etc/examples/pinot/pinot_example_datasource_quickstart.yaml && \
             superset import_dashboards -p /etc/examples/pinot/pinot_example_dashboard.json'
```

4\. Go to SuperSet UI: <http://localhost:8088/> to play around with dashboard.
{% endtab %}
{% endtabs %}

## Advanced Setup

### Adding Pinot Database

In order to add Pinot cluster as a database, a SQLAlchemy URI is required.

The format of URI is:

`pinot://<pinot-broker-host>:<pinot-broker-port><pinot-broker-path>?controller=<pinot-controller-host>:<pinot-controller-port>`

E.g.

> `pinot://pinot-broker:8099/query/sql?controller=http://pinot-controller:9000/`

Below is an example for the QuickStart cluster, you can click `TEST CONNECTION` button to check if Pinot cluster is successfully connected.

![Add Pinot cluster as a new Database](https://content.gitbook.com/content/gYpmZ5dnYUh7aQjLUJ9b/blobs/DK16H5GpaIcxFvb3dfb1/image.png)

### Adding Pinot Table

User can add an existing table into Superset:

![Add Table Definition](https://content.gitbook.com/content/gYpmZ5dnYUh7aQjLUJ9b/blobs/zZuVmG84jhRj0CLKfQXP/image.png)

![Table Definition](https://content.gitbook.com/content/gYpmZ5dnYUh7aQjLUJ9b/blobs/6bQ7HAikoa3QbEqHmZYV/image.png)

User can edit table/column definition by clicking the `edit` button left to the table name.

### Configuring time column

User can configure an existing column `mergedTimeMillis` as temporal and set `Datetime Format` accordingly.

![Configure time column](https://content.gitbook.com/content/gYpmZ5dnYUh7aQjLUJ9b/blobs/Ad7tmTZti90JcBbo0dPX/image.png)

### Adding a derived column

User can also add a new column by setting the expression.

![Add a simple derived column](https://content.gitbook.com/content/gYpmZ5dnYUh7aQjLUJ9b/blobs/cmt2RHQGydxd4kFBVZts/image.png)

Another example:

![Add a derived column with Pinot UDFs](https://content.gitbook.com/content/gYpmZ5dnYUh7aQjLUJ9b/blobs/sqd5HEgF048ITfJGshxg/image.png)
