PowerUser Plugin for dbt

Hover Over a dbt Model Reference or Macro to See Its Depth and Who Uses It

Hover over a dbt macro or ref() in VS Code. See which models use the macro and how deep the model sits, then ask Altimate Code to explain it.

Hover over a dbt model reference or macro to see its depth and who uses it
TL;DR
  • What it is. Hover cards on every ref() and macro call in a dbt model, from the PowerUser Plugin for dbt. Each card carries an Altimate Code action, which needs a free Altimate API key.
  • Who it is for. Analytics engineers who join a team, inherit a long dbt model or review a pull request full of Jinja.
  • What you get. The depth and columns behind each ref(), the models that use each macro, and an explanation one click away.

Long dbt models mix SQL with ref() calls and macros. The compiled SQL shows the result of the Jinja, but it hides where each piece came from. Before you change either one, you need two answers. What does the referenced model contain, and what does the macro do? Hover cards answer both inside the file you are reading.

Hover Over a Model Reference to See Depth and Columns

Hover over any ref() and a card appears. On ref('stg_orders') it reads DAG Depth 1, which means the longest path from a source to that model is one node. So stg_orders is a staging model that reads straight from a source. The card also lists the columns this model pulls from it, here order_id and status.

Use the depth to judge how far a change travels. A staging model at depth 1 feeds every model built on top of it. A high depth means many layers sit underneath. A wrong number there may start far upstream.

The hover card on ref('stg_orders') at line 11 of orders.sql. It reads DAG Depth 1, The longest path of models between a source and this model is 1 nodes long, then lists the ref stg_orders, the columns order_id and status, and an Explain transformation action.

Click Explain transformation on the card. Altimate Code walks through what the referenced model selects, filters, joins and aggregates, step by step.

Hover Over a Macro to See Which Models Use It

Hover over a macro call and the card names the macro and the models that reference it. In the demo, pct_of_total is used only by orders. Two actions sit on the card: Explain what this macro does and Find risky usages. The second action checks every call for:

  • Missing arguments.
  • Wrong argument types.
  • Edge cases the macro does not handle.
  • Anti-patterns in how the macro is called.

Run it before you change a macro that several models share. A macro used by one model is cheap to change. A macro used by twenty models needs a plan.

The hover card on the pct_of_total macro call at line 55. It reads (Macro) pct_of_total, (Referenced by) orders, and offers Explain what this macro does and Find risky usages.

Spotlight 5 video, dbt ref() and macros explained on hover

Go From the Whole Model Down to One Dependency

Each action opens its own Altimate Code session, so one chat explains the model and another explains a macro. Altimate Code asks before it runs a shell command, such as a search for every file that calls the macro. You approve it once, always or not at all. Start with the whole model, then open a second session for the one macro you do not trust.

Two Altimate Code chat tabs, Explain: stg_orders and Explain macro: pct_of_total, with a Permission required card for a bash command that searches SQL files for pct_of_total, offering Allow once, Allow always and Reject.

The hover actions guide lists every action on each card.

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