Documentation
¶
Overview ¶
Package dbt exposes dbt artifacts (manifest.json, run_results.json, catalog.json, sources.json) and dbt Cloud as SQL.
Schemas:
main artifact tables, selectors and DAG walks (offline, no credentials) cloud dbt Cloud Admin API v2/v3 and the Discovery API (dbt_cloud secret) unified runs / task_runs in the shape shared by the orchestrator workers
Attach it from DuckDB:
ATTACH 'dbt' (TYPE vgi, LOCATION '/abs/path/to/bin/vgi-dbt-worker');
Index ¶
Constants ¶
const ( // CloudSecretType is the DuckDB secret type holding dbt Cloud credentials. CloudSecretType = "dbt_cloud" // DefaultBaseURL is dbt Cloud's North America multi-tenant host. DefaultBaseURL = "https://cloud.getdbt.com" // MaxAttempts bounds retries of 429/5xx responses. MaxAttempts = 5 // Timeout bounds every request. Timeout = 60 * time.Second )
const ( MainSchemaComment = "dbt artifact tables (manifest, run_results, catalog, sources), selectors and DAG walks." CloudSchemaComment = "dbt Cloud Admin API (jobs, runs, environments) and Discovery API (models, tests, sources)." UnifiedSchemaComment = "runs and task_runs in the shape shared by every orchestrator worker." )
MainSchemaComment, CloudSchemaComment and UnifiedSchemaComment are the schema comments.
const CatalogComment = "" /* 133-byte string literal not displayed */
CatalogComment is the catalog's one-line description in directories.
const CatalogDocMD = "# dbt\n\n" +
"**dbt artifacts and dbt Cloud as SQL.** DuckDB's `read_json` turns a `manifest.json` into one row holding a " +
"project-specific `STRUCT` with one field per node, which is slow to infer, different for every project, and " +
"fully materialized before the first row. This worker streams the same file into flat tables whose columns do " +
"not change between projects or dbt releases (manifest schema v7 to v12), and skips unselected compiled SQL " +
"without decoding it, so the first rows of a 300 MB manifest arrive in well under a second.\n\n" +
"The `main` schema reads artifact files you already have (local paths and globs, https URLs, the bundled " +
"`sample://` jaffle_shop artifacts, or a dbt Cloud run's artifacts) and needs no credentials. Run artifact triage " +
"first on an unfamiliar file: an unknown schema version becomes a row, not a crash. The `cloud` schema reads the " +
"dbt Cloud Admin and Discovery APIs with a `dbt_cloud` secret, and the `unified` schema exposes runs and task runs " +
"in the shape every orchestrator worker shares, so dbt runs union with Airflow, Dagster or Prefect runs.\n\n" +
"See dbt's [artifact reference](https://docs.getdbt.com/reference/artifacts/dbt-artifacts) and the " +
"[dbt Cloud API docs](https://docs.getdbt.com/docs/dbt-cloud-apis/overview)."
CatalogDocMD is the catalog's long human-facing description.
const CatalogName = "dbt"
CatalogName is the name DuckDB attaches the worker under.
const SourceURL = "https://github.com/Query-farm/vgi-dbt"
SourceURL is where this worker's code lives.
const Version = "0.2.0"
Version is the worker version. ci/check-version.sh checks release tags (vX.Y.Z) against it, and the catalog advertises it to DuckDB.
Variables ¶
var CatalogTags = map[string]string{ "vgi.title": "dbt Artifacts", "vgi.subtitle": "Stream dbt manifest, run results, catalog and freshness artifacts, and dbt Cloud runs, into stable SQL tables.", "vgi.doc_llm": catalogDocLLM, "vgi.doc_md": CatalogDocMD, "vgi.source_url": SourceURL, "vgi.icon_url": "https://query.farm/media-kit/products/vgi/vgi-logo.png", "vgi.license": "0BSD", "vgi.author": "Query.Farm", "vgi.copyright": "Copyright 2026 Query Farm LLC - https://query.farm", "vgi.keywords": keywordsArray("dbt, dbt cloud, manifest.json, run_results.json, analytics engineering, dag, lineage, data quality"), "vgi.support_contact": SourceURL + "/issues", "vgi.support_policy_url": SourceURL + "#support", "vgi.agent_test_tasks": mustJSON(agentTestTasks), }
CatalogTags are the catalog-level discovery tags.
var CloudSecretTypeSpec = vgi.SecretTypeSpec{ Name: CloudSecretType, Description: "dbt Cloud API credentials: a service or personal access token, the account id and the account's access URL.", Schema: arrow.NewSchema([]arrow.Field{ secretField("token", "dbt Cloud service token or personal access token, sent as 'Authorization: Token <token>'.", true), secretField("account_id", "Numeric dbt Cloud account id (Account settings, or the number after /accounts/ in a dbt Cloud URL).", false), secretField("base_url", "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.", false), secretField("discovery_url", "Discovery (metadata) GraphQL endpoint. Derived from base_url when omitted, e.g. https://metadata.cloud.getdbt.com/graphql.", false), secretField("environment_id", "Default environment id for the Discovery API functions (cloud.models, cloud.tests, cloud.sources).", false), }, &cloudSecretMetadata), }
CloudSecretTypeSpec registers CREATE SECRET (TYPE dbt_cloud, ...).
var SchemaCategories = []category{
{Name: "manifest", Title: "Manifest", Description: "Tables over manifest.json: nodes, sources, exposures, macros, groups and declared columns."},
{Name: "semantic", Title: "Semantic Layer Definitions", Description: "Metrics and semantic models declared in manifest.json."},
{Name: "lineage", Title: "DAG and Lineage", Description: "Dependency edges and blended descendant/ancestor walks over the DAG."},
{Name: "runs", Title: "Run Results", Description: "Node results, phase timings and source freshness from run_results.json and sources.json."},
{Name: "catalog", Title: "Warehouse Catalog", Description: "Warehouse-observed columns from catalog.json."},
{Name: "selectors", Title: "Selectors", Description: "A strict, enumerated subset of dbt node selection."},
{Name: "reference", Title: "Reference and Triage", Description: "Artifact triage, schema versions and unique_id / relation helpers."},
{Name: "cloud", Title: "dbt Cloud Admin API", Description: "Accounts, projects, environments, jobs, runs, run steps and run artifacts."},
{Name: "discovery", Title: "dbt Cloud Discovery API", Description: "Applied-state models, tests and sources with latest execution and freshness."},
{Name: "unified", Title: "Unified Orchestrator Shape", Description: "runs / task_runs with the columns shared by every orchestrator worker."},
}
SchemaCategories group functions in docs and agent tools. Every function's vgi.category must name one of these.
Functions ¶
Types ¶
type ArtifactFile ¶
ArtifactFile is one resolved artifact: Local is readable on disk, Display is what the user named (reported in artifact_path columns).
type ArtifactScanState ¶
type ArtifactScanState struct {
Files []ArtifactFile
FileIdx int
SecIdx int
Offset int64
InSection bool
IsArray bool
First bool
Ordinal int64
Meta FileMeta
MetaLoaded bool
Opt string
Calls int
}
ArtifactScanState is the resumable cursor (exported: gob-encoded over HTTP).
type CloudScanState ¶
type CloudScanState struct {
Started bool
Done bool
Offset int64
Query string
Path string
Cursor int64
After string
Arg int64
}
CloudScanState is a dbt Cloud scan cursor. It never holds credentials.
type DiscoveryState ¶
type DiscoveryState struct {
EnvironmentID int64
After string
Started bool
Done bool
UniqueIDs []string
}
DiscoveryState is the GraphQL cursor.
type FileMeta ¶
type FileMeta struct {
Type string
SchemaURL string
SchemaVersion int
DbtVersion string
GeneratedAt string
InvocationID string
Env string
}
FileMeta is an artifact's metadata block (exported: it rides in scan state).
func (FileMeta) VersionLabel ¶
VersionLabel renders the schema version as "v12" ("" when unknown).
type InfoState ¶
type InfoState struct {
Files []ArtifactFile
Next int
}
InfoState is artifact_info's cursor: the next file to describe.
type ParseSelectorState ¶
ParseSelectorState is the single-batch cursor.
type SchemaVersionsState ¶
type SchemaVersionsState struct{ Done bool }
SchemaVersionsState is the (single-batch) cursor of the schema_versions table.
type UnifiedState ¶
type UnifiedState struct {
Mode string // "artifacts", "cloud", "cloud_run"
Files []ArtifactFile
Next int
Scan ArtifactScanState
Cloud CloudScanState
RunID int64
CloudURL string
}
UnifiedState covers both the artifact and the dbt Cloud variants.