DEV Community

DashboardGPT
DashboardGPT

Posted on Originally published at dashboardgpt.org

Apache Superset + AI: adding natural language to your BI stack

We run DashboardGPT's questions on Apache Superset. This guide covers what AI means for Superset today, three ways to add plain-English questions, the architecture behind them, where they break and the safety rules to set first.

Key takeaways

  • Superset runs queries and draws charts, but expects people to write SQL or build charts by hand. Plain-English questions come from a layer you add.
  • There are three ways to add that layer: a helper inside SQL Lab, a separate text-to-SQL service, or a canvas on top of Superset.
  • Five steps turn a question into a chart: schema context, prompt, SQL checks, running it through Superset and choosing the chart. Most wrong answers come from unclear data, not the model.
  • You can build this yourself on Superset. Or you can use a tool like DashboardGPT that already runs it on Superset.

What AI in Superset means today

Apache Superset is a popular open-source BI tool (BI means business intelligence, the charts and reports a company runs on). It connects to most SQL databases and has a SQL editor called SQL Lab, many chart types and a dashboard builder. For teams that want BI without licence fees, it is a natural choice.

Its limit is the person using it. To get value from Superset, you write SQL in SQL Lab or build charts by hand. That is fine for analysts. But a sales lead or a founder may just want to know why churn went up last month. For them, SQL is a wall.

AI can remove that wall, and it shows up in three places:

  • Built in. Superset adds features with each release. Check the release notes for the version you run, because this area moves fast.
  • Plugins and add-ons. Community extensions that help someone writing SQL, for example by drafting a query inside SQL Lab. The person still reads and checks the SQL.
  • An external layer. A separate tool that takes a plain-English question, writes the query, sends it to Superset to run and brings the chart back. Superset keeps doing what it is good at.

Which one you need depends on who asks the questions. If your analysts already live in SQL Lab, a helper there saves time. If the people asking cannot read SQL, you need a layer that works in plain English and shows the SQL only when someone asks.

We run natural-language questions on Superset in production for DashboardGPT. The trade-offs in this guide come from running it, not from a demo.

Three ways to add natural language to Superset

Teams usually pick one of three routes. The table shows who each suits and what it costs you.

Approach Who it suits What you build or buy Main trade-off
SQL Lab assistant Analysts who already read SQL A helper inside the SQL editor that drafts a query for review Needs someone who can check SQL, and answers stay inside SQL Lab
External text-to-SQL service Teams with platform engineers A separate service with column profiling, prompts, query checks, an interface and permissions The most control, and the most upkeep
A canvas on top of Superset Mixed teams, including people who do not write SQL A chat and canvas layer where Superset runs the queries and draws the charts Less custom control. Follow-up questions and context come ready-made

SQL Lab assistant

This is the smallest step. An analyst types a request, the helper drafts a query, and the analyst reads it, fixes it and runs it. It speeds up people who already know SQL. It does not help the colleague who cannot read the query, so it rarely changes who gets answers.

External text-to-SQL service

Here you build the full path yourself: profiling, prompts, checks, an interface and permissions. It gives you control over every step, including which AI model you call. It also makes you the owner of every fix, and each new model release or Superset upgrade is yours to test.

A canvas on top of Superset

Here the layer is a product. Answers land as cards you can move, group and link to the question they came from, and a follow-up knows which chart you mean. You give up some control over the internals. In return you skip the build and get the whole line of thought on one page.

A few questions help you choose:

  • Who will ask the questions: analysts, or people who do not write SQL?
  • Do answers need to be kept, moved around and built on, or is each question a one-off?
  • Do you have engineers who can own prompts, query checks and permissions over the long run?
  • Must the data and the AI calls stay inside your own network?

DashboardGPT takes the third route. If you want the first two, the guide to building an LLM chat interface for Superset walks through the code.

Architecture: from question to chart

Whichever route you choose, a question takes the same five steps to become a Superset chart. The AI layer handles the first three. Superset runs the query and draws the result.

Diagram of five steps from a plain-English question to a chart. The AI layer builds the schema context, builds the prompt and checks the SQL. Then Apache Superset runs the query and the chart is chosen.

Schema context, prompt and checks come from the AI layer. Superset runs the query.

1. Schema context

A schema is the list of tables and columns in your data. Before the AI can write a query, it needs to know what each column means, and names alone rarely help. Column names like amt, dt and status_cd tell a model very little.

Semantic profiling fills the gap. It is a scan that labels each column before anyone asks a question: its type, its role (a date, an amount, a category or an ID), its units and its links to other tables. Semantic column profiling explains it in more detail. DashboardGPT does this for you when you upload a file or connect a source.

2. Prompt

The prompt joins the question, the column labels and a short set of rules, such as which date column to use and what to do when a question is unclear. Good tools work in small steps. First they find the number you want, how to split it and any filters. Then they match each part to a real column, and only then do they write the query.

When the question is genuinely ambiguous, the best answer is a short question back to the user, not a guess.

3. SQL validation

The SQL is checked before it runs. It must only read data, never change it, and it can only use tables and columns that exist. It must also stay under set limits on rows and run time. A query that fails a check is repaired or rejected, and never sent to the database.

4. Execution through the Superset API

Once a query passes, the layer sends it to Superset, so it runs over the same connection and access rules Superset already uses. Superset has a REST API for this. A minimal call looks like this:

import requests

BASE = "https://superset.example.com"

def run_query(session: requests.Session, database_id: int, sql: str) -> dict:
    # session is already logged in to Superset with a read-only account
    r = session.post(
        f"{BASE}/api/v1/sqllab/execute/",
        json={"database_id": database_id, "sql": sql,
              "runAsync": False, "queryLimit": 5000},
    )
    r.raise_for_status()
    return r.json()
Enter fullscreen mode Exit fullscreen mode

The guide to building an LLM chat interface for Superset has the full version, including the login.

5. Chart choice

The shape of the result picks the chart. A single number becomes a metric card, a trend over time becomes a line chart, and a comparison of groups becomes a bar chart. Superset draws the chart, and a short written note explains what it shows and quotes the numbers.

Try it on the demo data: “Show weekly active users by plan for the last 12 weeks” Run it on the demo dataset

Where text-to-SQL breaks, and the fixes

Most wrong answers come from the data, not the model. Here are the common problems and how to fix each one.

Problem Example Fix
Unclear columns Three date columns: date, created and updated. Mark the main date column. Ask the user when it is not clear.
Wrong join Revenue counted twice after orders are joined to order lines. Set the join keys in the profile. Use tables that are already summed when you can.
Date grain A monthly average worked out as an average of daily averages. Sum to months first. Then take the average.
Business terms Product and sales mean different things by "active user". Agree on one meaning. Store it once and reuse it.
Status codes status = 3 means "cancelled". Turn codes into plain labels during profiling.
Time zones Daily counts shift at midnight UTC compared with local time. Set one time zone for the workspace and always use it.

A join links two tables, such as orders and customers. Date grain is the time unit you count by, such as day, week or month.

The pattern is the same each time. The more meaning you give the AI up front, the less it has to guess. For a deeper look at each problem, read text-to-SQL failure patterns, which covers seven patterns that break and a fix for each.

Test it before you trust it

A plain-English layer that answers confidently and wrongly is worse than no layer. Before you let anyone rely on it, test it on questions where you already know the answer.

  1. Pick a table you already chart in Superset and know well.
  2. Write ten to twenty questions, from simple ("total revenue last month") to hard ("revenue per customer by plan, excluding refunds").
  3. Compare each answer with the number you already trust, and note which of the common problems above caused every miss.
  4. Fix the cause once, in the column labels or the shared definitions, and ask the failed questions again.
  5. Repeat after every change to the data, the prompts or the AI model.

Our 50-question accuracy test kit gives you a ready-made set in five levels of difficulty, plus a way to score the results. It works on any tool, not only ours.

Build or buy: guardrails, row-level security and tenant isolation

You can build a plain-English layer on Superset yourself. You will need column profiling, prompts for the model, SQL checks and chart rules, plus an interface, permissions and a plan for model updates. That can make sense for a team with platform engineers who want to own every part.

Whichever way you go, set these guardrails before the first live question. Guardrails are rules that stop a query from doing harm.

  • Read-only access. The AI's database login should never be able to write or delete.
  • Row and time limits. Cap how many rows come back and how long a query can run, so one broad question cannot slow the database.
  • Show the SQL. Every answer should let the user open the query behind it.
  • Log questions and queries. The log shows which terms confuse people and where the profile needs work.
  • Keep AI keys under your control. With bring your own key, the AI calls run on your own account. You choose the provider, the model and the spending limit.

Row-level security

People should only see data they are allowed to see. Superset supports row-level security and roles for its own users. If your AI layer connects with one shared account, those rules do not follow the person asking. You then need to apply the same rules in the layer, or run each query as the person who asked.

Tenant isolation

If several teams or customers share the layer, keep their data, questions and answers apart. A mistake here shows one team's numbers to another, so test it as carefully as you test the answers.

What DashboardGPT ships

DashboardGPT builds these parts on top of Superset, so you do not have to:

  • Automatic profiling of uploaded files and connected sources.
  • Questions turned into SQL, with checks before anything runs.
  • Charts drawn by Superset, with written notes that quote their numbers.
  • An infinite canvas where follow-up questions keep their context.
  • Bring your own AI key on every plan.
  • Each workspace kept apart from every other, with roles for who sees what. Private or self-hosted setup is on Enterprise.

Try it on the demo data: “Which plan has the highest churn rate this quarter?” See the Superset-powered answer

Getting answers back into Superset dashboards

Superset dashboards are built for watching known numbers. They show a fixed set of charts that refresh on a schedule, and they do that job well, so keep them. Exploring is a different job. When you want to know why a number moved, you ask a question, look at the answer and ask a narrower one. A fixed grid makes that slow. Our look at moving from dashboards to a canvas explains why.

Most teams split the work like this: Superset dashboards for the weekly numbers everyone watches, and a conversational canvas for the questions those numbers raise. The two connect in both directions:

Getting started

  1. Try the playground. See plain-English questions answered by Superset charts on a demo dataset, with no signup.
  2. Upload a CSV or Excel export. Pick a table you already chart in Superset, and ask the same questions in plain English.
  3. Compare the results with your Superset chart to check that the numbers match.
  4. Plan for live data. Warehouse connections are coming soon on the Team plan.

Ready to try it? Open the playground, sign up, look at pricing or contact us if you want a private setup.

Frequently asked questions

Does Apache Superset have built-in AI?

Superset runs queries and draws charts. Plain-English questions are usually added as a layer on top, and Superset adds features with each release, so check the notes for the version you run. DashboardGPT is one such layer. It uses Superset to run queries and draw charts, and adds chat and an infinite canvas.

Can I ask Superset questions in plain English?

Yes, with a plain-English layer on top. Your question is turned into SQL and checked, then Superset runs it on your database. You get back a chart with a short written explanation.

Is text-to-SQL accurate enough for business use?

It is accurate for most everyday questions when the columns are well described. It gets worse with unclear column names, complex joins and business terms people disagree on. That is why column profiling and visible SQL matter.

Does this replace my Superset dashboards?

No. Dashboards are best for watching known numbers. A conversational canvas is best for exploring the questions those dashboards raise. Most teams use both.

How do I stop AI queries from changing my data?

Give the AI layer a read-only database login, check every query before it runs, and cap rows and run time. Showing the SQL behind each answer lets people spot a problem early.

Which databases work?

Superset supports most SQL databases. In DashboardGPT, CSV and Excel uploads work on every plan. Warehouse connections are coming soon on the Team plan.


Originally published on DashboardGPT Learn. DashboardGPT lets you ask questions of your data in plain English and get charts back. You can try it in the playground without an account.

Top comments (0)