PowerUser Plugin for dbt

Profile a dbt Query in One Click and Get Its Bugs, Anti-Patterns and Fixes Ranked

Profile a slow dbt query in one click. Altimate Code reviews the compiled SQL for correctness bugs, anti-patterns and cost, then ranks the fixes.

Profile a dbt query in one click and get its bugs, anti-patterns and fixes ranked
TL;DR
  • What it is. A Profile Query button in the Query Results panel. It sends your compiled SQL to Altimate Code with the prompt written. Altimate Code then runs its own SQL tools on it.
  • Who it is for. Analytics engineers with a slow dbt query, or a model they cannot fully trust. The model returns rows, but is it right in every case?
  • What you get. A report that leads with correctness bugs, lists the anti-patterns and ranks the fixes. You apply them in the same chat.

A slow dbt query is easy to notice. A wrong one is not. A model can return plausible rows for months and still hide a bug in one branch of a CASE expression. Reviewing it by hand means reading every CTE. Asking a chatbot means writing a prompt that names every check you care about. You only find the checks you thought to ask for. That gap grows as more of your SQL comes from an AI assistant.

Click Profile Query Once the Query Returns Results

Run the query the way you already do, with Cmd+Enter on a Mac or Control+Enter elsewhere. Once results come back, a Profile Query button becomes available in the Query Results toolbar. It appears only when there is data to profile.

The Query Results panel for customers.sql in the jaffle-shop-core-demo project, where you profile a slow dbt query. Badge 1 marks the Profile Query button next to Optimize Warehouse, and badge 2 marks the label query result 100 x 14.

Clicking it opens an Altimate Code chat named after your file. The full prompt is already written. The SQL it sends is the compiled query, which is what your warehouse runs. It falls back to the raw text only when no compiled version exists.

The prompt asks for four things, in this order:

OrderCheckExample finding
1CorrectnessA NULL case that returns 0
2PerformanceAn aggregation before a join
3CostA full scan the warehouse cannot prune
4Best practiceSELECT * in the outer query

Read the Correctness Bug Before the Style Warnings

Altimate Code calls its analyze and rewrite tools, which add a deterministic check on top of the model's answer. The report puts correctness first. On the customers model it found that two columns handle the no-orders case differently.

The Profile: customers.sql chat under the heading Correctness bug, the real finding, not just style. It explains that 38 of 100 customers never ordered, so 38% of customers show a return_rate of 0%, and suggests else null.

Of 100 customers, 38 never placed an order. The model reports a 0% return rate for all 38, when the right value is NULL. The sql_analyze tool then lists three more findings:

  • SELECT * in the outer query.
  • A division by a column that can be zero.
  • An aggregation before a join.

The sql_analyze findings block: a warning for SELECT * in the outer query, a warning for division by the column number_of_orders, an info note that DATEDIFF is dialect-specific, and an error flagging aggregation performed before JOIN on customer_orders.

Apply the Ranked Fixes in the Same Session

The report ends with recommendations ranked by impact. Fixing the NULL handling comes first, because it affects 38% of rows. Replacing SELECT * with an explicit column list comes second. The report also names a pattern to keep. Here, the pre-aggregate-then-join pattern needed no rewrite.

Spotlight 1 video, dbt SQL review in one click with Profile Query

Ask Altimate Code to patch the model, or ask a follow-up about any finding, in the same chat. For the rest of the panel, see the Query Results panel guide.

Install the dbt VS Code extension

Frequently Asked Questions

Install the dbt VS Code Extension. Free to Start.

Power User for dbt is an open source VS Code extension that adds column lineage, autocomplete, AI docs, query previews and health checks to your dbt project.

The Altimate platform: team spend by warehouse, dbt column lineage and an Altimate Code session recap