# Querying The Dbt Information Schema

Use when answering questions about a dbt v2 project's own metadata, which models...

- Repository: https://github.com/dbt-labs/dbt-agent-skills (750 stars)
- Category: Testing
- License: Apache-2.0
- Last updated: 2026-10-29
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add dbt-labs/dbt-agent-skills --skill querying-the-dbt-information-schema -g -a claude-code -y`
Codex: `npx skills add dbt-labs/dbt-agent-skills --skill querying-the-dbt-information-schema -g -a codex -y`
Cursor: `npx skills add dbt-labs/dbt-agent-skills --skill querying-the-dbt-information-schema -g -a cursor -y`
Gemini CLI: `npx skills add dbt-labs/dbt-agent-skills --skill querying-the-dbt-information-schema -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add dbt-labs/dbt-agent-skills`

## Description

Use when answering questions about a dbt v2 project's own metadata, which models, sources, tests, columns, configs, tags, packages or lineage exist, what is untested or undocumented, what depends on what, how long models took in the last run, or when using `dbt show --info`, `{{ info_schema() }}`, `--generate-info-schema`, `target/info_schema/`, or writing `dbt check` SQL. Prefer this over grepping YAML or parsing `manifest.json` on dbt v2.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Querying the dbt Information Schema

The dbt Information Schema is a set of SQL views over your project's metadata: models, sources, tests, columns, DAG edges, configs, and run results. You query it with DuckDB SQL, locally, without touching the warehouse.

Use it to answer "what is in this project" questions with one SQL query, instead of grepping YAML or loading a 70 MB `manifest.json`.

## Contents

| You want to… | Go to |
|---|---|
| Check the project can use this | [Prerequisites](#prerequisites) |
| Answer a one-off question | [Route A: `dbt show`](#route-a-dbt-show-default) (default) |
| Run many queries, script them, or use `run_results_latest` | [Route B: DuckDB on the parquet files](#route-b-duckdb-on-the-parquet-files) |
| Avoid wrong answers from tricky columns | [Column gotchas](#column-gotchas) |
| Understand why a view is empty | [What is populated when](#what-is-populated-when) |
| Copy a working query | [Common queries](#common-queries) |
| Enforce a rule on every build | [Turning a query into a check](#turning-a-query-into-a-check) |

**Which route?** Use `dbt show` unless you have a reason not to. It always reads the metadata from the latest dbt command, and it needs nothing installed. Switch to DuckDB when it is installed and you will run many queries, because each `dbt show` call costs about 0.6 s versus about 0.1 s for DuckDB. The trade-off is that you must refresh the parquet files yourself.

| | Route A: `dbt show` | Route B: DuckDB on parquet |
|---|---|---|
| Table names | `{{ info_schema('models') }}` (Jinja, bare view name) | `dbt.models`, `dbt_rt.run_results` (after `.read views.sql`), or `'dbt.models.parquet'` |
| Freshness | Updated by `build`, `run`, `check` by default | Updated only by a command run with `--generate-info-schema` |
| Needs | dbt v2 | dbt v2 once, plus the `duckdb` CLI or a parquet library |
| `dbt_rt.run_results_latest` | Not available | Available |
| Speed per query | ~0.2, 0.7 s | ~0.1 s |

## Prerequisites

The rest: https://github.com/dbt-labs/dbt-agent-skills/blob/HEAD/skills/dbt/skills/querying-the-dbt-information-schema/SKILL.md
