Skip to content
mentoor

Topic 3 of 5 · 5 min read

Catalog entries that agents can use

Goal: Document a table's grain, units and caveats so that an AI agent asked a question about it picks the right column.

Document a table so that a stranger, human or AI agent, who has never met its author would pick the right column and the right filter on the first try. Column names alone never carry that much meaning.

Check yourself · 1 of 3

Which table description helps a text-to-SQL agent avoid double counting?

Choose one answer

Why it matters

An analyst can ask a colleague what status = 3 means. A text-to-SQL agent such as one built on Claude, ChatGPT or Gemini cannot. It sees table names, column names and whatever descriptions the catalog gives it, then guesses. If revenue, revenue_net and revenue_adj all exist with no descriptions, it will pick one and answer with full confidence. The description is the only place the meaning lives, so the catalog is part of the prompt.

What to write

For each table:

  1. Grain. One row per what. "One row per order line per day" settles most join and double-counting questions.
  2. Purpose and scope. What question it answers, and what it excludes, such as test orders or refunds.
  3. Owner and freshness. Linked from the ownership entry.

For each column that is not obvious:

  1. Meaning in business words, not a restatement of the name. "Order total after discounts, before tax" beats "the order amount".
  2. Unit and type of value. Euros or cents, UTC or local time, a percentage as 0.15 or 15.
  3. Allowed values. What each code in status means.
  4. Caveats. Known gaps, such as "before 2024-03 this column is null for web orders".

Write in dbt description fields or the catalog's own editor, so the text sits in version control next to the model and shows in the docs site.

Before and after

Weak:

- name: amount
  description: The amount.
- name: status
  description: Order status.

Fixed:

- name: amount_eur
  description: Order total in euros after discounts, before tax and shipping. Refunds are separate rows in refunds_daily.
- name: status
  description: "Lifecycle state. 1 = placed, 2 = paid, 3 = shipped, 9 = cancelled. Revenue reports use status 2 and 3 only."

What goes wrong

  • Descriptions that restate the name. "customer_id: the customer id" teaches nothing and fills the catalog with noise.
  • Missing caveats. The agent returns a clean trend line across a period where the column was empty.
  • Two columns, no guidance. When near-duplicates exist, say which one to use for which question, and mark the other deprecated.
  • Drifting copy. Docs kept in a separate wiki fall behind the model. Keep them in the model file and review them in the pull request.

Test it: ask an agent a question about the table using only the catalog text, and check the SQL it writes.

Examples

Two revenue columns

A table has revenue and revenue_net. Asked for 'total sales last month', an agent picks revenue, which includes tax. Adding 'Gross, includes VAT. Do not use for sales reporting; use revenue_net' to the first description removes the guess.

A caveat that saves a trend line

device_type is null for all web sessions before 2024-03. Without the note, an agent charts mobile share from January and shows a false jump in March. With the note it can restrict the query or warn the reader.

Key points

  • Start every table description with its grain: one row per what.
  • Describe columns in business words, with unit, allowed values and known gaps.
  • A text-to-SQL agent reads the catalog as its only source of meaning, so descriptions act like prompt text.
  • When near-duplicate columns exist, state which to use for which question and deprecate the rest.
  • Keep descriptions in the model file under version control and review them with the code.

Common mistakes

  • Writing descriptions that only repeat the column name.
  • Leaving out units, so cents and euros or UTC and local time are mixed.
  • Omitting the grain, which leads to double-counted joins.
  • Keeping docs in a wiki separate from the model, so they go stale.

Check yourself · 2 of 3

Which column description is best?

Choose one answer

Check yourself · 3 of 3

A column is null for all rows before March 2024. Where should that be recorded?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic