TVL Managed Superset

Apache Superset SQL Lab: Explore Your Data 2026

SQL Lab tutorial in Apache Superset: execute queries, autocomplete, virtual datasets, sharing, async queries.

The SQL Lab is the SQL editor integrated into Apache Superset. It's the favorite tool of data analysts to explore quickly, prototype datasets, and prepare charts. This tutorial covers essential features and best practices in 2026.

1. What is SQL Lab for?

Three main uses:

  • Ad-hoc exploration: ask a quick question to data;
  • Prototyping virtual datasets before building a dashboard;
  • Sharing queries among data team members.

If you want to access SQL Lab without configuration, TVL Managed Superset enables it by default for Alpha+ roles.

2. SQL Lab access

Superset UI → SQL → SQL Lab. The editor opens with:

  • a database selector (your connections);
  • a schema and table explorer;
  • a SQL input area with autocomplete;
  • a results panel.

3. Execute a first query

SELECT
  DATE_TRUNC('day', created_at) AS day,
  COUNT(*) AS orders,
  SUM(amount) AS revenue
FROM orders
WHERE created_at >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY 1
ORDER BY 1 DESC
LIMIT 1000;

Click Run or Ctrl+Enter. Results appear at the bottom with tabular preview and CSV/JSON export button.

4. Contextual autocomplete

SQL Lab provides:

  • autocomplete of table and column names;
  • preview of column types;
  • syntax highlighting per dialect (Postgres, Snowflake, BigQuery…);
  • keyboard shortcuts (Ctrl+Space for suggestions).

5. Save a query

  1. Click Save;
  2. Give a name and description;
  3. Optionally, mark as Template to include in the team gallery.

Your saved queries are accessible from SQL → Saved Queries.

6. Create a virtual dataset

Once a working query, transform into a reusable dataset for charts:

  1. Click the Explore button at the top right of the results;
  2. Define a dataset name (e.g., orders_daily_summary);
  3. Save.

This virtual dataset appears in Datasets and can be used to create charts like a physical dataset.

7. Jinja templating

SQL Lab supports Jinja for parameterized queries:

SELECT *
FROM orders
WHERE created_at BETWEEN '{{ from_dttm }}' AND '{{ to_dttm }}'
  AND tenant_id = '{{ current_user_id() }}'

Useful for contextual queries (per user, per role). This configuration is applied by default on TVL Managed Superset, which follows community best practices.

8. Async queries

With the GLOBAL_ASYNC_QUERIES feature flag enabled, long queries run in the background via Celery. The user can keep working, the result arrives when ready. Essential to explore a slow data warehouse (cf. Celery async).

9. Sharing and collaboration

  • Direct link: copy the URL of a saved query to share;
  • Gallery: queries marked Template visible to the whole team;
  • Export in CSV/JSON for non-Superset users.

10. Best practices

  • Systematic LIMIT: avoid loading millions of rows in the browser;
  • Mandatory time filter on fact tables: otherwise full scan;
  • EXPLAIN before heavy queries to understand cost;
  • No DML: SQL Lab must be configured read-only on connection credentials;
  • Document queries: name + description + tags to facilitate search.

11. SQL Lab security

SQL Lab gives direct access to connected databases. To secure:

  • Read-only credentials on the database side;
  • Disable SQL Lab for Gamma roles (business users);
  • Centralized logs of all executed queries;
  • Cost estimate enabled to prevent very expensive queries (cf. our hardening guide).

12. Conclusion

SQL Lab is the number one productivity weapon of a data analyst on Superset. Combined with virtual datasets and the embedded SDK, it's one of the most complete exploration and production environments in open source.

Want the benefits of Apache Superset without the friction of installation and maintenance? Deploy your instance in 3 clicks with TVL Managed Superset, hosted in Europe (OVHcloud, Roubaix, France).

For more: virtual datasets, Jinja templating, async queries.