querying-the-dbt-information-schema
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…
от dbt-labs★ 776 звёзд на GitHub
Установить querying-the-dbt-information-schema в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
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 |
| Answer a one-off question | Route A: dbt show (default) |
Run many queries, script them, or use run_results_latest |
Route B: DuckDB on the parquet files |
| Avoid wrong answers from tricky columns | Column gotchas |
| Understand why a view is empty | What is populated when |
| Copy a working query | Common queries |
| Enforce a rule on every build | 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
- dbt v2 only. Run
dbt --versionfirst. The docs mark this feature "Available in v2". On dbt Core 1.x, fall back tomanifest.json. - Project metadata must exist.
dbt build,dbt run, anddbt checkwrite it by default.dbt parseanddbt compilewrite it with--generate-info-schema. If none of these has run,dbt show --infofails withInfoSchemaUnavailable(dbt1656) and names a command to run. - Know what the metadata reflects.
select command, generated_at from {{ info_schema('invocations') }} order by generated_at desclists the dbt commands behind it. Mention the latest one in your answer. - If you get 0 rows from a view that should have data, refresh the metadata with
dbt parse --generate-info-schemaand retry.parsedoes not connect to the warehouse.compile,runandbuilddo, so ask before running them. - Only local runs are here. Runs from dbt platform jobs or another machine are not in the local metadata. For those, use the job's own artifacts.
Route A: dbt show (default)
# List every available view (unknown names print the full list)
dbt show --info nonexistent
# One view, all rows, clean JSON on stdout
dbt show --quiet --info models --limit -1 --output json
# Ad-hoc SQL (DuckDB dialect)
dbt show --quiet --output json --limit -1 --inline "
select resource_type, count(*) n
from {{ info_schema('dag_nodes') }}
group by 1 order by 2 desc"
# Discover a view's columns yourself
dbt show --limit -1 --inline "describe select * from {{ info_schema('node_columns') }}"
--info <view> is shorthand for --inline "select * from {{ info_schema('<view>') }}". dbt runs the query on an embedded DuckDB, so you don't need to install DuckDB.
Rules that prevent wrong answers
| Rule | Why |
|---|---|
Put a literal {{ info_schema('view') }} call in every --inline query. |
dbt routes the query to DuckDB only when the SQL contains a literal call. info_schema(my_var) or a bare dbt.models sends it to the warehouse. It then takes 10+ seconds and fails with errors like Schema '<db>.DBT' does not exist. A slow query or a warehouse error means the query went to the wrong engine. A misrouted query also writes target/inline_<hash>.sql and overwrites target/run_results.json; a correctly routed one leaves target/ alone. |
Pass bare view names: --info models, info_schema('models'). |
dbt.models is rejected as an unknown view. |
Use --limit -1 when you need every row. |
The default limit is 10, so counts and lists are silently truncated. |
Use --quiet --output json when you will parse the output. |
Without --quiet, a version banner and an execution summary wrap the JSON. The table output also truncates wide columns. Errors still print under --quiet, and the exit code is 1. |
Filter enabled on both sides when counting resources. |
models and data_tests include disabled rows. dag_nodes holds only enabled resources. The counts will not match |
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/view-columns.md
FAQ
Что делает скилл querying-the-dbt-information-schema?
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.
Как установить скилл querying-the-dbt-information-schema?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл querying-the-dbt-information-schema запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…