Apache Superset
Apache Superset is a modern data exploration and visualization platform. This article explains how to create visualizations using data stored in YDB.
Installation of dependencies
To connect to YDB from Superset, install the ydb-sqlalchemy driver.
The installation method depends on your Superset setup. For detailed instructions, see the official documentation.
Adding a database connection to YDB
Native connection using SQLAlchemy driver
To connect to YDB from Apache Superset version 5.0.0 and higher, follow these steps:
-
In the Apache Superset toolbar, hover over Settings and select Database Connections.
-
Click the + DATABASE button.
The Connect a database wizard will appear.
-
In Step 1 of the wizard, choose YDB from the Supported databases list. If the YDB option is not available, make sure that all the steps from prerequisites are completed.
-
In Step 2 of the wizard, enter the YDB credentials in the corresponding fields:
- Display Name. The YDB connection name in Apache Superset.
- SQLAlchemy URI. A string in the format
ydb://{host}:{port}/{database_name}, where host and port are parts of the endpoint of the YDB cluster to which the connection will be made, and database_name is the path to the database.

-
To enhance security, you can specify credentials parameters in the Secure Extra field under the Advanced / Security tab.
Define the parameters as follows:
PasswordAccess TokenService Account{ "credentials": { "username": "...", "password": "..." } }{ "credentials": { "token": "...", } }{ "credentials": { "service_account_json": { "id": "...", "service_account_id": "...", "created_at": "...", "key_algorithm": "...", "public_key": "...", "private_key": "..." } } } -
Click CONNECT.
-
To save the database connection, click FINISH.
For more information about configuring a YDB connection, refer to the YDB section in the official documentation.
Creating a dataset
To create a dataset for a YDB table, follow these steps:
-
In the Apache Superset toolbar, hover over the + button and select SQL query.
-
In the DATABASE drop-down list, select the YDB database connection.
-
Enter the SQL query in the right section of the page. For example,
SELECT * FROM <ydb_table_name>.Tip
To create a dataset for a table located in a subdirectory of a YDB database, specify the table path in the table name. For example:
SELECT * FROM "<path/to/subdirectory/table_name>";-
Click RUN to test the SQL query.

-
Click the down arrow next to the SAVE button, then click Save dataset.
The Save or Overwrite Dataset dialog box appears.
-
In the Save or Overwrite Dataset dialog box, select Save as new, enter the dataset name, and click SAVE & EXPLORE.
After creating datasets, you can use data from YDB to create charts in Apache Superset. For more information, refer to the Apache Superset documentation.
Creating a chart
Let's create a sample chart with the dataset from the
episodestable that is described in the YQL tutorial.The table contains the following columns:
- series_id
- season_id
- episode_id
- title
- air_date
Let's say that we want to make a pie chart to show how many episodes each season contains.
To create a chart, follow these steps:
-
In the Apache Superset toolbar, hover over the + button and select Chart.
-
In the Choose a dataset drop-down list, select a dataset for the
episodestable. -
In the Choose chart type pane, select
Pie chart. -
Click CREATE NEW CHART.
-
In the Query pane, configure the chart:
- In the DIMENSIONS drop-down list, select the
season_idcolumn. - In the METRIC field, specify the
COUNT(title)function. - In the FILTERS field, specify the
series_id in (2)filter.
- In the DIMENSIONS drop-down list, select the
-
Click CREATE CHART.
The pie chart will appear in the preview pane on the right.

-
Click SAVE.
The Save chart dialog box will appear.
-
In the Save chart dialog box, in the CHART NAME field, enter the chart name.
-
Click SAVE.
-