Skip to content

dbt

Stream dbt manifest, run results, catalog and freshness artifacts, and dbt Cloud runs, into stable SQL tables

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/dbt/index.md to help me query dbt with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Triage every artifact in a target directory

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT artifact_type, schema_version, dbt_version, support_status FROM dbt.main.artifact_info('sample://jaffle_shop/v12/*.json') ORDER BY artifact_type

Quick start

Choose where to run dbt, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'dbt' AS dbt (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-dbt'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

dbt_cloud credentials

dbt Cloud API credentials: a service or personal access token, the account id and the account's access URL.

Get these credentials →
secret.sql
CREATE SECRET dbt_cloud (
    TYPE dbt_cloud,
    token          '<DBT_CLOUD_TOKEN>',  -- secret
    account_id     '<account_id>',
    base_url       '<base_url>',
    discovery_url  '<discovery_url>',
    environment_id '<environment_id>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT artifact_type, schema_version, dbt_version, support_status FROM dbt.main.artifact_info('sample://jaffle_shop/v12/*.json') ORDER BY artifact_type
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'dbt' AS dbt (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Query dbt artifacts (manifest, run results, catalog, source freshness) and dbt Cloud runs, jobs and Discovery metadata as SQL tables.

Catalog

Everything dbt exposes once attached — read straight from the worker's released build.

dbt 3 schemas
cloud 4 tables · 6 functions

dbt Cloud Admin API (jobs, runs, environments) and Discovery API (models, tests, sources).

Schema examples (11)
Examples (11)

Find your account id

SELECT id, name, plan FROM dbt.cloud.accounts ORDER BY id;

Active projects

SELECT id, name FROM dbt.cloud.projects WHERE state = 1 ORDER BY name;

Deployment environments

SELECT id, name, deployment_type
FROM dbt.cloud.environments
WHERE type = 'deployment'
ORDER BY id;

Scheduled jobs and their cron

SELECT id, name, schedule_cron
FROM dbt.cloud.jobs
WHERE schedule_enabled
ORDER BY id;
7 more examples

Failure counts per job since a date

SELECT job_name, count(*) FILTER (WHERE status = 'Error') AS failed,
  count(*) AS runs
FROM dbt.cloud.runs()
WHERE created_at >= TIMESTAMPTZ '2026-01-01'
GROUP BY job_name
ORDER BY failed DESC;

Recent successful runs of one job

SELECT id, status, duration_seconds
FROM dbt.cloud.runs()
WHERE job_id = 42 AND status = 'Success'
ORDER BY id DESC
LIMIT 10;

Steps of a run

SELECT step_index, name, status
FROM dbt.cloud.run_steps(70403103)
ORDER BY step_index;

Top-level JSON artifacts of a run

SELECT path, artifact_url
FROM dbt.cloud.run_artifacts(70403103)
WHERE path LIKE '%.json' AND path NOT LIKE '%/%'
ORDER BY path;

Models whose last execution failed

SELECT name, last_run_status, execution_time
FROM dbt.cloud.models(environment_id := 218762)
WHERE last_run_status = 'error'
ORDER BY name;

Test results in production by status

SELECT last_run_status, count(*) AS tests
FROM dbt.cloud.tests(environment_id := 218762)
GROUP BY last_run_status
ORDER BY last_run_status;

Stale sources in production

SELECT unique_id, freshness_status, round(age_seconds / 3600) AS hours_old
FROM dbt.cloud.sources(environment_id := 218762)
WHERE freshness_status <> 'pass'
ORDER BY unique_id;
Tables
accounts 1 example10 cols

dbt Cloud accounts the dbt_cloud secret's token can see

Columns
idnot null BIGINT
Account id (numeric; the secret's ACCOUNT_ID).
name VARCHAR
Account name.
plan VARCHAR
Billing plan, e.g. enterprise, team, developer.
state INTEGER
Lifecycle state code (1 = active, 2 = deleted).
run_slots BIGINT
Number of jobs the account can run concurrently.
developer_seats BIGINT
Number of licensed IDE (developer) users.
read_only_seats BIGINT
Number of licensed read-only users.
locked BOOLEAN
Whether the account is locked.
created_at TIMESTAMP WITH TIME ZONE
Creation time.
updated_at TIMESTAMP WITH TIME ZONE
Last update.
ConstraintsPRIMARY KEY (id)
Example

Find your account id

SELECT id, name, plan FROM dbt.cloud.accounts ORDER BY id;
Link
environments 1 example12 cols

Environments in the dbt Cloud account (where environment_id and project_id come from)

Columns
idnot null BIGINT
Environment id (numeric; pass it to the Discovery functions).
account_id BIGINT
Owning account (id in cloud.accounts).
project_id BIGINT
Project the environment belongs to (id in cloud.projects). = filters push down.
name VARCHAR
Environment name.
type VARCHAR
development or deployment.
deployment_type VARCHAR
production, staging or NULL.
dbt_version VARCHAR
dbt version or release track.
use_custom_branch BOOLEAN
Whether a custom git branch is used.
custom_branch VARCHAR
The custom branch, else NULL.
state INTEGER
Lifecycle state code (1 = active, 2 = deleted).
created_at TIMESTAMP WITH TIME ZONE
Creation time.
updated_at TIMESTAMP WITH TIME ZONE
Last update.
ConstraintsPRIMARY KEY (id)
Example

Deployment environments

SELECT id, name, deployment_type
FROM dbt.cloud.environments
WHERE type = 'deployment'
ORDER BY id;
Link
jobs 1 example18 cols

Job definitions in the dbt Cloud account

Columns
idnot null BIGINT
Job definition id (numeric; runs reference it as job_id).
account_id BIGINT
Owning account (id in cloud.accounts).
project_id BIGINT
Project (id in cloud.projects). = filters push down.
environment_id BIGINT
Environment the job runs in (id in cloud.environments). = filters push down.
name VARCHAR
Job name.
description VARCHAR
Free-text summary of what the job does.
job_type VARCHAR
scheduled, ci, merge or other.
execute_steps VARCHAR[]
dbt commands the job runs, in order.
schedule_cron VARCHAR
Cron schedule, when scheduled.
schedule_enabled BOOLEAN
triggers.schedule: whether the schedule is on.
generate_docs BOOLEAN
Whether the job generates docs (catalog.json).
run_generate_sources BOOLEAN
Whether the job checks source freshness (sources.json).
threads BIGINT
Number of dbt threads (settings.threads).
target_name VARCHAR
settings.target_name.
dbt_version VARCHAR
Pinned dbt version, else NULL (inherits the environment).
state INTEGER
Lifecycle state code (1 = active, 2 = deleted).
created_at TIMESTAMP WITH TIME ZONE
Creation time.
updated_at TIMESTAMP WITH TIME ZONE
Last update.
ConstraintsPRIMARY KEY (id)
Example

Scheduled jobs and their cron

SELECT id, name, schedule_cron
FROM dbt.cloud.jobs
WHERE schedule_enabled
ORDER BY id;
Link
projects 1 example10 cols

Projects in the dbt Cloud account

Columns
idnot null BIGINT
Project id (numeric dbt Cloud identifier).
account_id BIGINT
Owning account (id in cloud.accounts).
name VARCHAR
Project name.
description VARCHAR
Free-text project summary written by its owners.
dbt_project_subdirectory VARCHAR
Subdirectory of the repository holding dbt_project.yml.
connection_id BIGINT
Warehouse connection (numeric dbt Cloud id).
repository_id BIGINT
Git repository (numeric dbt Cloud id).
state INTEGER
Lifecycle state code (1 = active, 2 = deleted).
created_at TIMESTAMP WITH TIME ZONE
Creation time.
updated_at TIMESTAMP WITH TIME ZONE
Last update.
ConstraintsPRIMARY KEY (id)
Example

Active projects

SELECT id, name FROM dbt.cloud.projects WHERE state = 1 ORDER BY name;
Link
Table functions
models (environment_id := BIGINT) 1 example

Models in a dbt Cloud environment's applied state with their latest execution

Named arguments
environment_id := BIGINT
dbt Cloud environment id (the id column of dbt.cloud.environments); 0 uses the dbt_cloud secret's ENVIRONMENT_ID. · default 0
Returns columns
unique_id VARCHAR
Model unique id. = / IN filters push down (uniqueIds).
name VARCHAR
Model name.
description VARCHAR
Description.
package_name VARCHAR
Package.
materialized VARCHAR
Materialization.
db_name VARCHAR
Database.
db_schema VARCHAR
Schema.
alias VARCHAR
Relation identifier.
tags VARCHAR[]
Tags.
file_path VARCHAR
Source file path.
last_run_id BIGINT
Run that last executed the model.
last_run_status VARCHAR
Status of that execution: success, error or skipped.
last_run_error VARCHAR
Error message of a failed last execution.
last_success_run_id BIGINT
Last run in which it succeeded.
execute_started_at TIMESTAMP WITH TIME ZONE
Start of the last execution.
execute_completed_at TIMESTAMP WITH TIME ZONE
End of the last execution.
execution_time DOUBLE
Seconds the last execution took.
Example

Models whose last execution failed

SELECT name, last_run_status, execution_time
FROM dbt.cloud.models(environment_id := 218762)
WHERE last_run_status = 'error'
ORDER BY name;
Link
run_artifacts (run_id BIGINT) 1 example

Artifact files a dbt Cloud run saved, with the dbt-cloud:// URL the artifact tables read

Arguments
run_id BIGINT
dbt Cloud run id (cloud.runs().id).
Returns columns
run_id BIGINT
The run.
path VARCHAR
Artifact path within the run, e.g. manifest.json or compiled/....
artifact_url VARCHAR
dbt-cloud:// URL to pass to the artifact functions, e.g. dbt.main.nodes(artifact_url).
Example

Top-level JSON artifacts of a run

SELECT path, artifact_url
FROM dbt.cloud.run_artifacts(70403103)
WHERE path LIKE '%.json' AND path NOT LIKE '%/%'
ORDER BY path;
Link
run_steps (run_id BIGINT) 1 example

The steps (dbt commands) of one dbt Cloud run with status, timing and logs

Arguments
run_id BIGINT
dbt Cloud run id (cloud.runs().id).
Returns columns
run_id BIGINT
Run the step belongs to.
step_id BIGINT
Step id.
step_index INTEGER
1-based position in the run.
name VARCHAR
Step name, e.g. 'Invoke dbt with `dbt build`'.
status VARCHAR
Queued, Starting, Running, Success, Error or Cancelled.
status_code INTEGER
Numeric status.
started_at TIMESTAMP WITH TIME ZONE
Step start.
finished_at TIMESTAMP WITH TIME ZONE
Step end.
duration_seconds DOUBLE
finished_at - started_at.
logs VARCHAR
Step log text as returned by the API (may be truncated).
Example

Steps of a run

SELECT step_index, name, status
FROM dbt.cloud.run_steps(70403103)
ORDER BY step_index;
Link
runs (cursor := VARCHAR) 2 examples

Job runs in the dbt Cloud account, newest first, with job, status and date-range pushdown

Named arguments
cursor := VARCHAR
Incremental cursor: only runs with id greater than this run id are returned (store max(id) in a table and pass it back). '' = all runs. · default ""
Returns columns
id BIGINT
Run id. Also the incremental cursor: pass the largest id you have as cursor := '<id>'.
account_id BIGINT
Owning account.
project_id BIGINT
Project. = filters push down.
environment_id BIGINT
Environment. = filters push down.
job_id BIGINT
Job definition id. = filters push down (job_definition_id).
job_name VARCHAR
Job name.
status VARCHAR
Queued, Starting, Running, Success, Error or Cancelled. = / IN filters push down.
status_code INTEGER
Numeric status: 1, 2, 3, 10, 20, 30.
status_message VARCHAR
Error or cancellation message.
trigger_cause VARCHAR
Why the run started (trigger.cause), e.g. 'Kicked off from UI by ...'.
git_branch VARCHAR
Git branch run.
git_sha VARCHAR
Git commit run.
dbt_version VARCHAR
dbt version used.
created_at TIMESTAMP WITH TIME ZONE
When the run was queued. Range filters push down (created_at__range).
started_at TIMESTAMP WITH TIME ZONE
When execution started.
finished_at TIMESTAMP WITH TIME ZONE
When it finished.
duration_seconds DOUBLE
finished_at - started_at.
queued_seconds DOUBLE
started_at - created_at.
is_complete BOOLEAN
Whether the run has finished.
artifacts_saved BOOLEAN
Whether artifacts can be read with dbt-cloud://runs/<id>/<file>.
has_docs_generated BOOLEAN
catalog.json available.
has_sources_generated BOOLEAN
sources.json available.
href VARCHAR
Link to the run in dbt Cloud.
Examples (2)

Failure counts per job since a date

SELECT job_name, count(*) FILTER (WHERE status = 'Error') AS failed,
  count(*) AS runs
FROM dbt.cloud.runs()
WHERE created_at >= TIMESTAMPTZ '2026-01-01'
GROUP BY job_name
ORDER BY failed DESC;

Recent successful runs of one job

SELECT id, status, duration_seconds
FROM dbt.cloud.runs()
WHERE job_id = 42 AND status = 'Success'
ORDER BY id DESC
LIMIT 10;
Link
sources (environment_id := BIGINT) 1 example

Sources in a dbt Cloud environment's applied state with their latest freshness

Named arguments
environment_id := BIGINT
dbt Cloud environment id (the id column of dbt.cloud.environments); 0 uses the dbt_cloud secret's ENVIRONMENT_ID. · default 0
Returns columns
unique_id VARCHAR
Source unique id. = / IN filters push down (uniqueIds).
source_name VARCHAR
Source group name.
name VARCHAR
Table name.
identifier VARCHAR
Warehouse identifier.
db_name VARCHAR
Database.
db_schema VARCHAR
Schema.
description VARCHAR
Description.
loader VARCHAR
Declared loader.
freshness_status VARCHAR
pass, warn or error.
freshness_checked BOOLEAN
Whether freshness is checked.
max_loaded_at TIMESTAMP WITH TIME ZONE
Latest loaded_at value seen.
age_seconds DOUBLE
Seconds between max_loaded_at and the check.
snapshotted_at TIMESTAMP WITH TIME ZONE
When freshness was last checked.
freshness_run_id BIGINT
Run that checked it.
Example

Stale sources in production

SELECT unique_id, freshness_status, round(age_seconds / 3600) AS hours_old
FROM dbt.cloud.sources(environment_id := 218762)
WHERE freshness_status <> 'pass'
ORDER BY unique_id;
Link
tests (environment_id := BIGINT) 1 example

Tests in a dbt Cloud environment's applied state with their latest result

Named arguments
environment_id := BIGINT
dbt Cloud environment id (the id column of dbt.cloud.environments); 0 uses the dbt_cloud secret's ENVIRONMENT_ID. · default 0
Returns columns
unique_id VARCHAR
Test unique id. = / IN filters push down (uniqueIds).
name VARCHAR
Test name.
description VARCHAR
Description.
column_name VARCHAR
Column under test, for column tests.
test_type VARCHAR
GENERIC or SINGULAR.
last_run_id BIGINT
Run that last executed the test.
last_run_status VARCHAR
pass, fail, warn, error or skipped.
last_run_error VARCHAR
Failure message.
execute_completed_at TIMESTAMP WITH TIME ZONE
When the last execution finished.
execution_time DOUBLE
Seconds the last execution took.
Example

Test results in production by status

SELECT last_run_status, count(*) AS tests
FROM dbt.cloud.tests(environment_id := 218762)
GROUP BY last_run_status
ORDER BY last_run_status;
Link
main 1 table · 21 functions

dbt artifact tables (manifest, run_results, catalog, sources), selectors and DAG walks.

Schema examples (27)
Examples (27)

Triage every artifact in a target directory

SELECT artifact_type, schema_version, dbt_version, support_status FROM dbt.main.artifact_info('sample://jaffle_shop/v12/*.json') ORDER BY artifact_type;

Manifest versions across several dbt releases

SELECT schema_version, dbt_version, node_count FROM dbt.main.artifact_info('sample://jaffle_shop/*/manifest.json') ORDER BY dbt_version;

Schema version of a manifest

SELECT dbt.main.manifest_version('sample://jaffle_shop/v12/manifest.json') AS version;

Models tagged marts

SELECT name
FROM dbt.main.nodes('sample://jaffle_shop/v12/manifest.json')
WHERE dbt.main.selector_match(unique_id, fqn, tags, materialized, 'tag:marts,resource_type:model')
ORDER BY name;
23 more examples

See which atom of a selector is unsupported

SELECT term, kind, supported, reason
FROM dbt.main.parse_selector('tag:finance,+fct_orders')
ORDER BY term;

Model version from a unique_id

SELECT dbt.main.parse_unique_id('model.jaffle_shop.orders.v2').version AS version;

Canonical relation keys for every model

SELECT dbt.main.normalize_relation(db_name, db_schema, alias, NULL) AS relation
FROM dbt.main.nodes('sample://jaffle_shop/v12/manifest.json')
WHERE resource_type = 'model'
ORDER BY relation;

Models downstream of stg_orders

SELECT unique_id, depth
FROM dbt.main.descendants('model.jaffle_shop.stg_orders', manifest := 'sample://jaffle_shop/v12/manifest.json')
WHERE unique_id LIKE 'model.%'
ORDER BY depth, unique_id;

Sources a model ultimately reads

SELECT unique_id, depth
FROM dbt.main.ancestors('model.jaffle_shop.customers', manifest := 'sample://jaffle_shop/v12/manifest.json')
WHERE unique_id LIKE 'source.%'
ORDER BY unique_id;

Supported manifest versions and the dbt releases that write them

SELECT schema_version, dbt_version_range
FROM dbt.main.schema_versions
WHERE artifact_type = 'manifest' AND supported
ORDER BY schema_version;

Check an artifact against the support matrix

SELECT i.dbt_version, v.support_status
FROM dbt.main.artifact_info('sample://jaffle_shop/v12/manifest.json') i
JOIN dbt.main.schema_versions v USING (artifact_type, schema_version);

Count models by materialization

SELECT materialized, count(*) AS models
FROM dbt.main.nodes('sample://jaffle_shop/v12/manifest.json')
WHERE resource_type = 'model'
GROUP BY materialized
ORDER BY materialized;

Models with no description, in a dbt 1.3 (v7) manifest

SELECT name, description
FROM dbt.main.nodes('sample://jaffle_shop/v7/manifest.json')
WHERE resource_type = 'model' AND description = ''
ORDER BY name;

Documented columns per node

SELECT unique_id, count(*) AS documented
FROM dbt.main.node_columns('sample://jaffle_shop/v12/manifest.json')
WHERE description <> ''
GROUP BY unique_id
ORDER BY unique_id;

Most depended-upon resources

SELECT depends_on_id, count(*) AS dependents
FROM dbt.main.depends_on('sample://jaffle_shop/v12/manifest.json')
GROUP BY depends_on_id
ORDER BY dependents DESC, depends_on_id
LIMIT 5;

Macros used by each model

SELECT unique_id, depends_on_id
FROM dbt.main.depends_on('sample://jaffle_shop/v12/manifest.json', kind := 'macros')
WHERE unique_id LIKE 'model.%'
ORDER BY ALL;

Sources with freshness checks configured

SELECT unique_id, loaded_at_field
FROM dbt.main.sources('sample://jaffle_shop/v12/manifest.json')
WHERE freshness IS NOT NULL
ORDER BY unique_id;

Which models feed each exposure

SELECT name, unnest(depends_on_ids) AS feeds_from
FROM dbt.main.exposures('sample://jaffle_shop/v12/manifest.json')
ORDER BY ALL;

List metrics and their type

SELECT name, metric_type, expression
FROM dbt.main.metrics('sample://jaffle_shop/v12/manifest.json')
ORDER BY name;

Semantic models and how many measures each defines

SELECT name, model_ref, json_array_length(measures) AS measures
FROM dbt.main.semantic_models('sample://jaffle_shop/v12/manifest.json')
ORDER BY name;

Groups and their owners

SELECT name, owner_email
FROM dbt.main.groups('sample://jaffle_shop/v12/manifest.json')
ORDER BY name;

Macros defined by the project itself

SELECT name, path
FROM dbt.main.macros('sample://jaffle_shop/v12/manifest.json')
WHERE package_name = 'jaffle_shop'
ORDER BY name;

Results of a run by status

SELECT status, count(*) AS nodes
FROM dbt.main.run_results('sample://jaffle_shop/v12/run_results.json')
GROUP BY status
ORDER BY status;

Slowest model executions across an archive of runs

SELECT unique_id, round(execution_time, 3) AS seconds FROM dbt.main.run_results('sample://jaffle_shop/*/run_results.json') WHERE unique_id LIKE 'model.%' ORDER BY execution_time DESC LIMIT 5;

Count compile and execute phases in a run

SELECT name, count(*) AS phases
FROM dbt.main.run_timings('sample://jaffle_shop/v12/run_results.json')
GROUP BY name
ORDER BY name;

Column count per relation

SELECT table_name, count(*) AS columns
FROM dbt.main.catalog_columns('sample://jaffle_shop/v12/catalog.json')
GROUP BY table_name
ORDER BY table_name;

How stale each checked source is

SELECT unique_id, status, round(age_seconds / 86400) AS days_old
FROM dbt.main.source_freshness('sample://jaffle_shop/v12/sources.json')
ORDER BY unique_id;
Tables
schema_versions 2 examples6 cols

Static compatibility matrix: which dbt artifact schema versions the worker supports (supported / best_effort / unsupported).

Columns
artifact_typenot null VARCHAR
manifest, run_results, catalog or sources.
schema_versionnot null VARCHAR
Schema version, e.g. v12.
dbt_version_range VARCHAR
dbt-core releases that write this version.
supported BOOLEAN
True when inside the verified support window.
support_status VARCHAR
supported, best_effort (newer than verified) or unsupported (older than the window).
notes VARCHAR
What changed in this version.
ConstraintsPRIMARY KEY (artifact_type, schema_version)
Examples (2)

Supported manifest versions and the dbt releases that write them

SELECT schema_version, dbt_version_range
FROM dbt.main.schema_versions
WHERE artifact_type = 'manifest' AND supported
ORDER BY schema_version;

Check an artifact against the support matrix

SELECT i.dbt_version, v.support_status
FROM dbt.main.artifact_info('sample://jaffle_shop/v12/manifest.json') i
JOIN dbt.main.schema_versions v USING (artifact_type, schema_version);
Link
Scalar functions
manifest_version (path VARCHAR) 2 examples

Schema version of a local dbt artifact (e.g. 'v12'), read from its metadata block only

Arguments
path VARCHAR
Path to a local dbt artifact file (manifest.json or any other artifact).
ReturnsVARCHAR
Examples (2)

Schema version of a manifest

SELECT dbt.main.manifest_version('sample://jaffle_shop/v12/manifest.json') AS version;
SELECT dbt.main.manifest_version('sample://jaffle_shop/v9/manifest.json') AS version;
Link
normalize_relation (database VARCHAR, db_schema VARCHAR, identifier VARCHAR, quoting VARCHAR) 2 examples

Canonical db.schema.table join key for a warehouse relation, honouring dbt quoting

Arguments
database VARCHAR
Database (nodes.db_name); NULL or '' is omitted.
db_schema VARCHAR
Schema (nodes.db_schema).
identifier VARCHAR
Relation identifier (nodes.alias or sources.identifier).
quoting VARCHAR
Quoting policy as a JSON object of database/schema/identifier booleans (dbt quoting config); NULL means no part is quoted.
ReturnsVARCHAR
Examples (2)

Canonical relation keys for every model

SELECT dbt.main.normalize_relation(db_name, db_schema, alias, NULL) AS relation
FROM dbt.main.nodes('sample://jaffle_shop/v12/manifest.json')
WHERE resource_type = 'model'
ORDER BY relation;
SELECT dbt.main.normalize_relation('"Analytics"', 'Main', 'Orders', '{"database": true}') AS relation;
Link
parse_unique_id (unique_id VARCHAR) 2 examples

Split a dbt unique_id into resource_type, package, name and model version

Arguments
unique_id VARCHAR
A dbt unique_id such as model.jaffle_shop.orders.v2 or source.jaffle_shop.raw.orders.
ReturnsSTRUCT of 4 fields
STRUCT 4 fields
  • resource_typeVARCHAR
  • packageVARCHAR
  • nameVARCHAR
  • versionVARCHAR
Examples (2)

Model version from a unique_id

SELECT dbt.main.parse_unique_id('model.jaffle_shop.orders.v2').version AS version;
SELECT p.resource_type, p.package, p.name
FROM (SELECT dbt.main.parse_unique_id('source.jaffle_shop.raw.raw_orders') AS p);
Link
selector_match (unique_id VARCHAR, fqn VARCHAR[], tags VARCHAR[], materialized VARCHAR, selector VARCHAR) 2 examples

True when a node matches a dbt selector (an enumerated subset of dbt's grammar); unsupported terms fail at bind

Arguments
unique_id VARCHAR
Node unique_id (nodes.unique_id).
fqn VARCHAR[]
Node fqn list (nodes.fqn).
tags VARCHAR[]
Node tags list (nodes.tags).
materialized VARCHAR
Node materialization (nodes.materialized); may be NULL.
selector VARCHAR
Constant dbt selector using only tag:/path:/fqn:/package:/resource_type:/config.materialized: and bare names; space = union, comma = intersection.
ReturnsBOOLEAN
Examples (2)

Models tagged marts

SELECT name
FROM dbt.main.nodes('sample://jaffle_shop/v12/manifest.json')
WHERE dbt.main.selector_match(unique_id, fqn, tags, materialized, 'tag:marts,resource_type:model')
ORDER BY name;
SELECT dbt.main.selector_match('model.shop.orders', ['shop', 'marts', 'orders'], ['marts'], 'table', 'path:models/marts') AS hit;
Link
Table functions
ancestors (unique_id VARCHAR, manifest := VARCHAR, max_depth := BIGINT, include_self := BOOLEAN) 2 examples

Every node upstream of a unique_id in a manifest's DAG (the + prefix operator), per input row

Positional arguments
unique_id VARCHAR
Root node unique_id (a literal or a column).
Named arguments
manifest := VARCHAR
Local path of the manifest.json whose DAG to walk (required). · default ""
max_depth := BIGINT
Stop after this many edges (1 = direct children/parents only). · default 64
include_self := BOOLEAN
Also emit the root itself at depth 0. · default false
Returns columns
root_id VARCHAR
The unique_id the walk started from (the input row).
unique_id VARCHAR
A node reached from root_id.
depth INTEGER
Edges between root_id and unique_id (0 = the root itself when include_self).
path VARCHAR[]
Shortest path from root_id to unique_id, both ends included.
Examples (2)

Sources a model ultimately reads

SELECT unique_id, depth
FROM dbt.main.ancestors('model.jaffle_shop.customers', manifest := 'sample://jaffle_shop/v12/manifest.json')
WHERE unique_id LIKE 'source.%'
ORDER BY unique_id;
SELECT unique_id, depth
FROM dbt.main.ancestors('model.jaffle_shop.stg_orders', manifest := 'sample://jaffle_shop/v12/manifest.json')
ORDER BY unique_id;
Link
artifact_info (path VARCHAR) 2 examples

Compatibility triage for dbt artifacts: type, schema version, dbt version, size and support status, one row per file

Arguments
path VARCHAR
Artifact file, glob (e.g. 'target/*.json'), https:// URL or dbt-cloud://runs/<run_id>/<artifact>.json.
Returns columns
path VARCHAR
The artifact file (as named, or the URL).
artifact_type VARCHAR
manifest, run_results, catalog or sources (from metadata.dbt_schema_version).
schema_version VARCHAR
Artifact schema version, e.g. v12.
dbt_version VARCHAR
dbt version that wrote the file.
generated_at TIMESTAMP WITH TIME ZONE
When dbt wrote the file.
invocation_id VARCHAR
dbt invocation id.
env JSON
metadata.env (DBT_ENV_CUSTOM_ENV_* values), as JSON.
node_count BIGINT
Entries in the main section: nodes (manifest), results (run_results, sources), nodes+sources (catalog).
bytes BIGINT
File size in bytes.
support_status VARCHAR
supported, best_effort or unsupported under the published support policy.
warning VARCHAR
Why the version is best_effort/unsupported; NULL when supported.
Examples (2)

Triage every artifact in a target directory

SELECT artifact_type, schema_version, dbt_version, support_status FROM dbt.main.artifact_info('sample://jaffle_shop/v12/*.json') ORDER BY artifact_type;

Manifest versions across several dbt releases

SELECT schema_version, dbt_version, node_count FROM dbt.main.artifact_info('sample://jaffle_shop/*/manifest.json') ORDER BY dbt_version;
Link
catalog_columns (path VARCHAR) 1 example

Warehouse-observed columns of every node and source relation in a catalog.json

Arguments
path VARCHAR
catalog.json to read (written by dbt docs generate): a local path, https:// URL or dbt-cloud://runs/<run_id>/catalog.json.
Returns columns
unique_id VARCHAR
Node or source the relation belongs to.
table_type VARCHAR
Warehouse relation type, e.g. BASE TABLE or VIEW.
column_name VARCHAR
Column name as the warehouse reports it.
column_index INTEGER
Ordinal position in the relation.
column_type VARCHAR
Warehouse data type.
comment VARCHAR
Warehouse column comment.
stats JSON
Relation-level statistics the adapter reported, as JSON.
owner VARCHAR
Relation owner, when reported.
table_database VARCHAR
Relation database.
table_schema VARCHAR
Relation schema.
table_name VARCHAR
Relation name.
Example

Column count per relation

SELECT table_name, count(*) AS columns
FROM dbt.main.catalog_columns('sample://jaffle_shop/v12/catalog.json')
GROUP BY table_name
ORDER BY table_name;
Link
depends_on (manifest VARCHAR, kind := VARCHAR) 2 examples

The direct dependency edges (depends_on) of every node, exposure, metric and semantic model in a manifest.json

Positional arguments
manifest VARCHAR
Path to a dbt manifest.json: a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/manifest.json (needs a dbt_cloud secret).
Named arguments
kind := VARCHAR
Which edges: 'nodes' (refs, sources, metrics) or 'macros'. · default "nodes"
Returns columns
unique_id VARCHAR
The dependent node.
depends_on_id VARCHAR
What it depends on (a node, source, metric or macro unique_id).
depth INTEGER
Always 1: this is the direct edge list; use descendants/ancestors for closure.
Examples (2)

Most depended-upon resources

SELECT depends_on_id, count(*) AS dependents
FROM dbt.main.depends_on('sample://jaffle_shop/v12/manifest.json')
GROUP BY depends_on_id
ORDER BY dependents DESC, depends_on_id
LIMIT 5;

Macros used by each model

SELECT unique_id, depends_on_id
FROM dbt.main.depends_on('sample://jaffle_shop/v12/manifest.json', kind := 'macros')
WHERE unique_id LIKE 'model.%'
ORDER BY ALL;
Link
descendants (unique_id VARCHAR, manifest := VARCHAR, max_depth := BIGINT, include_self := BOOLEAN) 2 examples

Every node downstream of a unique_id in a manifest's DAG (the + suffix operator), per input row

Positional arguments
unique_id VARCHAR
Root node unique_id (a literal or a column).
Named arguments
manifest := VARCHAR
Local path of the manifest.json whose DAG to walk (required). · default ""
max_depth := BIGINT
Stop after this many edges (1 = direct children/parents only). · default 64
include_self := BOOLEAN
Also emit the root itself at depth 0. · default false
Returns columns
root_id VARCHAR
The unique_id the walk started from (the input row).
unique_id VARCHAR
A node reached from root_id.
depth INTEGER
Edges between root_id and unique_id (0 = the root itself when include_self).
path VARCHAR[]
Shortest path from root_id to unique_id, both ends included.
Examples (2)

Models downstream of stg_orders

SELECT unique_id, depth
FROM dbt.main.descendants('model.jaffle_shop.stg_orders', manifest := 'sample://jaffle_shop/v12/manifest.json')
WHERE unique_id LIKE 'model.%'
ORDER BY depth, unique_id;
SELECT unique_id
FROM dbt.main.descendants('model.jaffle_shop.stg_payments', manifest := 'sample://jaffle_shop/v12/manifest.json', max_depth := 1)
WHERE unique_id LIKE 'model.%'
ORDER BY unique_id;
Link
exposures (manifest VARCHAR) 1 example

Every exposure (dashboard, notebook, application) declared in a manifest.json

Arguments
manifest VARCHAR
Path to a dbt manifest.json: a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/manifest.json (needs a dbt_cloud secret).
Returns columns
unique_id VARCHAR
Exposure unique id.
package_name VARCHAR
Package that declares it.
name VARCHAR
Exposure name.
exposure_type VARCHAR
dashboard, notebook, analysis, ml or application.
maturity VARCHAR
high, medium or low; NULL when unset.
url VARCHAR
Link to the exposure.
owner_name VARCHAR
Owner name.
owner_email VARCHAR
Owner email.
description VARCHAR
Description.
label VARCHAR
Display label.
tags VARCHAR[]
Tags.
meta JSON
Meta, as JSON.
depends_on_ids VARCHAR[]
Nodes and sources the exposure depends on.
path VARCHAR
YAML file path relative to its resource directory.
original_file_path VARCHAR
YAML file path relative to the project root.
Example

Which models feed each exposure

SELECT name, unnest(depends_on_ids) AS feeds_from
FROM dbt.main.exposures('sample://jaffle_shop/v12/manifest.json')
ORDER BY ALL;
Link
groups (manifest VARCHAR) 1 example

Every group (model ownership unit) declared in a manifest.json (v9+; older manifests return no rows)

Arguments
manifest VARCHAR
Path to a dbt manifest.json: a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/manifest.json (needs a dbt_cloud secret).
Returns columns
unique_id VARCHAR
Group unique id.
package_name VARCHAR
Package that declares it.
name VARCHAR
Group name.
owner_name VARCHAR
Owner name.
owner_email VARCHAR
Owner email.
path VARCHAR
YAML path relative to its resource directory.
original_file_path VARCHAR
YAML path relative to the project root.
Example

Groups and their owners

SELECT name, owner_email
FROM dbt.main.groups('sample://jaffle_shop/v12/manifest.json')
ORDER BY name;
Link
macros (manifest VARCHAR) 1 example

Every macro in a manifest.json, including those from dbt and installed packages

Arguments
manifest VARCHAR
Path to a dbt manifest.json: a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/manifest.json (needs a dbt_cloud secret).
Returns columns
unique_id VARCHAR
Macro unique id, e.g. macro.dbt.ref.
package_name VARCHAR
Package that defines the macro (dbt, dbt_duckdb, your project, ...).
name VARCHAR
Macro name.
macro_sql VARCHAR
Jinja source of the macro. Skipped without decoding when not selected.
path VARCHAR
File path relative to its macro directory.
arguments JSON
Documented arguments, as JSON.
depends_on_macros VARCHAR[]
Macros this macro calls.
Example

Macros defined by the project itself

SELECT name, path
FROM dbt.main.macros('sample://jaffle_shop/v12/manifest.json')
WHERE package_name = 'jaffle_shop'
ORDER BY name;
Link
metrics (manifest VARCHAR) 1 example

Every metric in a manifest.json, normalized across pre-MetricFlow (v7-v9) and MetricFlow (v10+) shapes

Arguments
manifest VARCHAR
Path to a dbt manifest.json: a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/manifest.json (needs a dbt_cloud secret).
Returns columns
unique_id VARCHAR
Metric unique id.
package_name VARCHAR
Package that declares it.
name VARCHAR
Metric name.
label VARCHAR
Display label.
metric_type VARCHAR
MetricFlow type (simple, ratio, derived, cumulative, conversion); calculation_method on pre-MetricFlow manifests (v7-v9).
description VARCHAR
Description.
expression VARCHAR
type_params.expr or the input measure (MetricFlow); expression/sql on older manifests.
filter_expression VARCHAR
Metric filter: where_filters joined with AND (MetricFlow), or 'field operator value' filters on older manifests.
agg VARCHAR
Aggregation for pre-MetricFlow metrics (calculation_method); NULL on MetricFlow metrics, whose aggregation lives on the measure.
agg_time_dimension VARCHAR
Time dimension: timestamp (pre-MetricFlow) or the measure's agg_time_dimension when set on the metric.
tags VARCHAR[]
Tags.
meta JSON
Meta, as JSON.
depends_on_ids VARCHAR[]
Nodes, semantic models and metrics it depends on.
group_name VARCHAR
Group, else NULL.
path VARCHAR
YAML path relative to its resource directory.
original_file_path VARCHAR
YAML path relative to the project root.
Example

List metrics and their type

SELECT name, metric_type, expression
FROM dbt.main.metrics('sample://jaffle_shop/v12/manifest.json')
ORDER BY name;
Link
node_columns (manifest VARCHAR) 1 example

Columns declared in YAML for each node and source in a manifest.json (the contract side, not the warehouse)

Arguments
manifest VARCHAR
Path to a dbt manifest.json: a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/manifest.json (needs a dbt_cloud secret).
Returns columns
unique_id VARCHAR
Node or source that declares the column.
name VARCHAR
Declared column name.
ordinal INTEGER
1-based position in the YAML declaration.
data_type VARCHAR
Declared data_type (contract), else NULL.
description VARCHAR
Column description.
tags VARCHAR[]
Column tags.
meta JSON
Column meta, as JSON.
constraints JSON
Declared column constraints (manifest v9+), as JSON.
Example

Documented columns per node

SELECT unique_id, count(*) AS documented
FROM dbt.main.node_columns('sample://jaffle_shop/v12/manifest.json')
WHERE description <> ''
GROUP BY unique_id
ORDER BY unique_id;
Link
nodes (manifest VARCHAR) 2 examples

Every node (model, test, seed, snapshot, analysis) in a dbt manifest.json, one row per node

Arguments
manifest VARCHAR
Path to a dbt manifest.json: a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/manifest.json (needs a dbt_cloud secret).
Returns columns
unique_id VARCHAR
dbt unique id, e.g. model.jaffle_shop.orders.
resource_type VARCHAR
model, test, seed, snapshot, analysis, operation, sql_operation or unit_test.
package_name VARCHAR
dbt package (project) that defines the node.
name VARCHAR
Node name.
relation_name VARCHAR
Fully quoted warehouse relation, e.g. "db"."main"."orders"; NULL for ephemeral models and tests without a relation.
db_name VARCHAR
Warehouse database the node builds into.
db_schema VARCHAR
Warehouse schema the node builds into.
alias VARCHAR
Relation identifier (alias) in the warehouse.
materialized VARCHAR
config.materialized: table, view, incremental, ephemeral, seed, snapshot, test, ...
incremental_strategy VARCHAR
config.incremental_strategy for incremental models, else NULL.
tags VARCHAR[]
Node tags.
meta JSON
The node's meta mapping, as JSON.
config JSON
The node's full resolved config, as JSON (adapter-specific keys included).
raw_code VARCHAR
Uncompiled SQL/Python source (raw_sql before dbt 1.3). Skipped without decoding when not selected.
compiled_code VARCHAR
Compiled SQL, present when the manifest was written after a compile/run. Skipped without decoding when not selected.
language VARCHAR
sql or python.
path VARCHAR
Path relative to the resource directory (models/, seeds/, ...).
original_file_path VARCHAR
Path relative to the project root, e.g. models/marts/orders.sql.
fqn VARCHAR[]
Fully qualified name: package, then directories, then the node name.
checksum VARCHAR
checksum.checksum of the source file; compare two manifests with IS DISTINCT FROM.
description VARCHAR
Documented description ('' when undocumented).
patch_path VARCHAR
YAML file that documents the node, e.g. jaffle_shop://models/marts/schema.yml.
group_name VARCHAR
Model group (manifest v9+), else NULL.
access VARCHAR
Model access: private, protected or public (manifest v9+), else NULL.
contract_enforced BOOLEAN
Whether the model contract is enforced (manifest v9+), else NULL.
deprecation_date TIMESTAMP WITH TIME ZONE
Model deprecation date (manifest v10+), else NULL.
manifest_version VARCHAR
Manifest schema version the row came from, e.g. v12.
generated_at TIMESTAMP WITH TIME ZONE
When dbt wrote the manifest (metadata.generated_at).
Examples (2)

Count models by materialization

SELECT materialized, count(*) AS models
FROM dbt.main.nodes('sample://jaffle_shop/v12/manifest.json')
WHERE resource_type = 'model'
GROUP BY materialized
ORDER BY materialized;

Models with no description, in a dbt 1.3 (v7) manifest

SELECT name, description
FROM dbt.main.nodes('sample://jaffle_shop/v7/manifest.json')
WHERE resource_type = 'model' AND description = ''
ORDER BY name;
Link
parse_selector (selector VARCHAR) 2 examples

Explain a dbt selector atom by atom and say which atoms selector_match supports and why not

Arguments
selector VARCHAR
A dbt selector string, e.g. 'tag:finance,config.materialized:table'.
Returns columns
term_index INTEGER
1-based index of the space-separated term the atom belongs to.
term VARCHAR
The atom's text, e.g. tag:finance.
kind VARCHAR
Method (tag, path, fqn, package, resource_type, config.materialized, name), graph_op, exclude, or the unsupported method name.
value VARCHAR
The value after the method.
negated BOOLEAN
True for atoms after --exclude.
supported BOOLEAN
Whether selector_match accepts the atom.
reason VARCHAR
Why the atom is unsupported and what to use instead; NULL when supported.
Examples (2)

See which atom of a selector is unsupported

SELECT term, kind, supported, reason
FROM dbt.main.parse_selector('tag:finance,+fct_orders')
ORDER BY term;
SELECT term, kind, supported
FROM dbt.main.parse_selector('tag:finance +fct_orders')
ORDER BY term_index;
Link
run_results (path VARCHAR) 2 examples

Per-node results from one or many run_results.json files (a glob scans an archive, one file per partition)

Arguments
path VARCHAR
run_results.json to read: a local path or glob (e.g. 'archive/**/run_results.json', one partition per file), an https:// URL, or dbt-cloud://runs/<run_id>/run_results.json.
Returns columns
invocation_id VARCHAR
dbt invocation id of the run (metadata.invocation_id).
unique_id VARCHAR
Node the result is for.
status VARCHAR
success, error, skipped (models); pass, fail, warn, error (tests); no-op (operations).
execution_time DOUBLE
Seconds spent on the node.
rows_affected BIGINT
adapter_response.rows_affected, when the adapter reports it.
failures BIGINT
Failing rows for tests, else NULL.
message VARCHAR
Status message or error text.
thread_id VARCHAR
dbt thread that ran the node.
adapter_response JSON
Raw adapter response, as JSON.
compile_started TIMESTAMP WITH TIME ZONE
Start of the compile phase.
execute_completed TIMESTAMP WITH TIME ZONE
End of the execute phase.
generated_at TIMESTAMP WITH TIME ZONE
When dbt wrote the file (metadata.generated_at).
artifact_path VARCHAR
File the row came from (useful with globs).
Examples (2)

Results of a run by status

SELECT status, count(*) AS nodes
FROM dbt.main.run_results('sample://jaffle_shop/v12/run_results.json')
GROUP BY status
ORDER BY status;

Slowest model executions across an archive of runs

SELECT unique_id, round(execution_time, 3) AS seconds FROM dbt.main.run_results('sample://jaffle_shop/*/run_results.json') WHERE unique_id LIKE 'model.%' ORDER BY execution_time DESC LIMIT 5;
Link
run_timings (path VARCHAR) 1 example

Compile and execute phase timings for every node in one or many run_results.json files

Arguments
path VARCHAR
run_results.json to read: a local path or glob (e.g. 'archive/**/run_results.json', one partition per file), an https:// URL, or dbt-cloud://runs/<run_id>/run_results.json.
Returns columns
invocation_id VARCHAR
dbt invocation id.
unique_id VARCHAR
Node the timing is for.
name VARCHAR
Phase: compile or execute.
started_at TIMESTAMP WITH TIME ZONE
Phase start.
completed_at TIMESTAMP WITH TIME ZONE
Phase end.
duration_seconds DOUBLE
completed_at - started_at in seconds.
Example

Count compile and execute phases in a run

SELECT name, count(*) AS phases
FROM dbt.main.run_timings('sample://jaffle_shop/v12/run_results.json')
GROUP BY name
ORDER BY name;
Link
semantic_models (manifest VARCHAR) 1 example

Every MetricFlow semantic model in a manifest.json (v10+; older manifests return no rows)

Arguments
manifest VARCHAR
Path to a dbt manifest.json: a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/manifest.json (needs a dbt_cloud secret).
Returns columns
unique_id VARCHAR
Semantic model unique id.
package_name VARCHAR
Package that declares it.
name VARCHAR
Semantic model name.
description VARCHAR
Description.
model_ref VARCHAR
The model it is built on, e.g. ref('orders').
db_name VARCHAR
Database of the underlying relation.
db_schema VARCHAR
Schema of the underlying relation.
identifier VARCHAR
Identifier (alias) of the underlying relation.
primary_entity VARCHAR
Declared primary_entity, else NULL.
entities JSON
Entities, as JSON.
dimensions JSON
Dimensions, as JSON.
measures JSON
Measures, as JSON.
defaults JSON
Defaults such as agg_time_dimension, as JSON.
group_name VARCHAR
Group, else NULL.
path VARCHAR
YAML path relative to its resource directory.
original_file_path VARCHAR
YAML path relative to the project root.
Example

Semantic models and how many measures each defines

SELECT name, model_ref, json_array_length(measures) AS measures
FROM dbt.main.semantic_models('sample://jaffle_shop/v12/manifest.json')
ORDER BY name;
Link
source_freshness (path VARCHAR) 1 example

Source freshness results from sources.json (dbt source freshness)

Arguments
path VARCHAR
sources.json to read (written by dbt source freshness): a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/sources.json.
Returns columns
unique_id VARCHAR
Source checked.
status VARCHAR
pass, warn, error or runtime error.
max_loaded_at TIMESTAMP WITH TIME ZONE
Latest loaded_at_field value found.
snapshotted_at TIMESTAMP WITH TIME ZONE
When the check ran.
age_seconds DOUBLE
snapshotted_at - max_loaded_at in seconds.
criteria JSON
warn_after / error_after criteria applied, as JSON.
error VARCHAR
Error message for runtime errors, else NULL.
artifact_path VARCHAR
File the row came from.
Example

How stale each checked source is

SELECT unique_id, status, round(age_seconds / 86400) AS days_old
FROM dbt.main.source_freshness('sample://jaffle_shop/v12/sources.json')
ORDER BY unique_id;
Link
sources (manifest VARCHAR) 1 example

Every source table declared in a manifest.json

Arguments
manifest VARCHAR
Path to a dbt manifest.json: a local path or glob, an https:// URL, or dbt-cloud://runs/<run_id>/manifest.json (needs a dbt_cloud secret).
Returns columns
unique_id VARCHAR
Source unique id, e.g. source.jaffle_shop.raw.orders.
package_name VARCHAR
Package that declares the source.
source_name VARCHAR
The source group name (first argument to source()).
name VARCHAR
Table name within the source (second argument to source()).
relation_name VARCHAR
Fully quoted warehouse relation.
loaded_at_field VARCHAR
Column used for freshness checks, else NULL.
freshness JSON
Freshness criteria (warn_after / error_after / filter), as JSON; NULL when not configured.
db_name VARCHAR
Warehouse database.
db_schema VARCHAR
Warehouse schema.
identifier VARCHAR
Warehouse table identifier.
loader VARCHAR
Declared loader (e.g. fivetran), '' when unset.
description VARCHAR
Source table description.
tags VARCHAR[]
Source tags.
meta JSON
Source meta, as JSON.
Example

Sources with freshness checks configured

SELECT unique_id, loaded_at_field
FROM dbt.main.sources('sample://jaffle_shop/v12/manifest.json')
WHERE freshness IS NOT NULL
ORDER BY unique_id;
Link
unified 2 functions

runs and task_runs in the shape shared by every orchestrator worker.

Schema examples (3)
Examples (3)

An archive of local dbt invocations as runs

SELECT run_id, pipeline, status, round(duration_seconds, 1) AS seconds FROM dbt.unified.runs(path := 'sample://jaffle_shop/*/run_results.json') ORDER BY started_at;

dbt Cloud job failures in the unified shape

SELECT pipeline, count(*) FILTER (WHERE status = 'failed') AS failures
FROM dbt.unified.runs()
WHERE queued_at >= TIMESTAMPTZ '2026-01-01'
GROUP BY pipeline
ORDER BY failures DESC;

Node outcomes of one invocation in the unified shape

SELECT status, count(*) AS tasks
FROM dbt.unified.task_runs(path := 'sample://jaffle_shop/v12/run_results.json')
GROUP BY status
ORDER BY status;
Table functions
runs (path := VARCHAR) 2 examples

dbt invocations (run_results.json) or dbt Cloud runs in the cross-orchestrator runs shape

Named arguments
path := VARCHAR
run_results.json file or glob; '' (default) reads dbt Cloud through the dbt_cloud secret. · default ""
Returns columns
orchestrator VARCHAR
'dbt' for a run_results.json invocation, 'dbt_cloud' for a dbt Cloud run.
run_id VARCHAR
dbt invocation_id, or the dbt Cloud run id.
pipeline VARCHAR
'dbt <command>' for an invocation (e.g. dbt build); the job name for a dbt Cloud run.
status VARCHAR
queued, running, success, failed, cancelled or skipped.
raw_status VARCHAR
The tool's own status: worst node status of an invocation, or the dbt Cloud status name.
trigger VARCHAR
schedule, manual, api, event or other (dbt Cloud); NULL for local invocations.
queued_at TIMESTAMP WITH TIME ZONE
When the run was queued (dbt Cloud created_at); NULL for local invocations.
started_at TIMESTAMP WITH TIME ZONE
When the run started.
ended_at TIMESTAMP WITH TIME ZONE
When the run ended.
duration_seconds DOUBLE
Wall-clock seconds.
url VARCHAR
Link to the run (dbt Cloud) or the run_results.json path.
Examples (2)

An archive of local dbt invocations as runs

SELECT run_id, pipeline, status, round(duration_seconds, 1) AS seconds FROM dbt.unified.runs(path := 'sample://jaffle_shop/*/run_results.json') ORDER BY started_at;

dbt Cloud job failures in the unified shape

SELECT pipeline, count(*) FILTER (WHERE status = 'failed') AS failures
FROM dbt.unified.runs()
WHERE queued_at >= TIMESTAMPTZ '2026-01-01'
GROUP BY pipeline
ORDER BY failures DESC;
Link
task_runs (path := VARCHAR, run_id := BIGINT) 1 example

dbt node results (or dbt Cloud run steps) in the cross-orchestrator task_runs shape

Named arguments
path := VARCHAR
run_results.json file or glob; '' (default) reads dbt Cloud through the dbt_cloud secret. · default ""
run_id := BIGINT
dbt Cloud run id whose run_results.json to read as node results; 0 = not set. · default 0
Returns columns
orchestrator VARCHAR
'dbt' or 'dbt_cloud'.
run_id VARCHAR
The run (invocation_id or dbt Cloud run id) the task belongs to.
task_run_id VARCHAR
Node unique_id for node results; '<run_id>:<step index>' for dbt Cloud steps.
task_name VARCHAR
Node unique_id, or the dbt Cloud step name.
status VARCHAR
queued, running, success, failed, cancelled or skipped.
raw_status VARCHAR
dbt node status (success, error, pass, fail, warn, skipped, ...) or dbt Cloud step status.
attempt INTEGER
Always 1 (dbt does not retry nodes inside one invocation).
started_at TIMESTAMP WITH TIME ZONE
Task start (compile start for nodes).
ended_at TIMESTAMP WITH TIME ZONE
Task end (execute end for nodes).
duration_seconds DOUBLE
Seconds the task took (execution_time for nodes).
url VARCHAR
Link to the dbt Cloud run, or the run_results.json path.
Example

Node outcomes of one invocation in the unified shape

SELECT status, count(*) AS tasks
FROM dbt.unified.task_runs(path := 'sample://jaffle_shop/v12/run_results.json')
GROUP BY status
ORDER BY status;
Link

Credentials

The secret type dbt declares, as reported by the worker itself.

dbt_cloud

How to get these credentials

dbt Cloud API credentials: a service or personal access token, the account id and the account's access URL.

secret.sql
CREATE SECRET dbt_cloud (
    TYPE dbt_cloud,
    token          '<DBT_CLOUD_TOKEN>',  -- secret
    account_id     '<account_id>',
    base_url       '<base_url>',
    discovery_url  '<discovery_url>',
    environment_id '<environment_id>'
);
Key Type Required Description
token secret VARCHAR — dbt Cloud service token or personal access token, sent as 'Authorization: Token <token>'.
account_id VARCHAR — Numeric dbt Cloud account id (Account settings, or the number after /accounts/ in a dbt Cloud URL).
base_url VARCHAR — Access URL of the account, e.g. https://cloud.getdbt.com (North America), https://emea.dbt.com, https://au.dbt.com, or a cell/single-tenant host such as https://ab123.us1.dbt.com. Default https://cloud.getdbt.com.
discovery_url VARCHAR — Discovery (metadata) GraphQL endpoint. Derived from base_url when omitted, e.g. https://metadata.cloud.getdbt.com/graphql.
environment_id VARCHAR — Default environment id for the Discovery API functions (cloud.models, cloud.tests, cloud.sources).

The worker doesn't mark which keys are required.

Needed by runstask_runsartifact_infocatalog_columnsdepends_onexposuresgroupsmacrosmetricsnode_columnsnodesrun_results and 10 more functions

Create the secret in the same session, after attaching dbt — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

Find your account id

SELECT id, name, plan FROM dbt.cloud.accounts ORDER BY id

Uses accounts

Active projects

SELECT id, name FROM dbt.cloud.projects WHERE state = 1 ORDER BY name

Uses projects

Deployment environments

SELECT id, name, deployment_type
FROM dbt.cloud.environments
WHERE type = 'deployment'
ORDER BY id

Uses environments

Scheduled jobs and their cron

SELECT id, name, schedule_cron
FROM dbt.cloud.jobs
WHERE schedule_enabled
ORDER BY id

Uses jobs

Failure counts per job since a date

SELECT job_name, count(*) FILTER (WHERE status = 'Error') AS failed,
  count(*) AS runs
FROM dbt.cloud.runs()
WHERE created_at >= TIMESTAMPTZ '2026-01-01'
GROUP BY job_name
ORDER BY failed DESC

Uses runsruns

Steps of a run

SELECT step_index, name, status
FROM dbt.cloud.run_steps(70403103)
ORDER BY step_index

Uses run_steps

41 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • In the bundled sample manifest sample://jaffle_shop/v12/manifest.json, how many models are materialized as table and how many as view?
  • Which tests failed (status fail or error) in sample://jaffle_shop/v12/run_results.json? Give their unique_ids.
  • Using sample://jaffle_shop/v12/manifest.json, which models are downstream of model.jaffle_shop.stg_orders?
  • What manifest schema versions are in the bundled samples sample://jaffle_shop/*/manifest.json, and which dbt version wrote each?
  • Which declared sources does model.jaffle_shop.customers ultimately read in sample://jaffle_shop/v12/manifest.json, and what loaded_at_field does each use?
  • Which macros defined by the jaffle_shop project itself are used by which models, in sample://jaffle_shop/v12/manifest.json?

dbt is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.