Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
56c29dd
chore: bump dbterd>=1.34 and artifact-parser>=1.0.1; make catalog.jso…
il-dat Nov 14, 2026
415462e
fix: sort column-lineage leaves so dbdocs-data.json is reproducible a…
il-dat Nov 14, 2026
4036a47
feat: opt-in --info-schema plugin reading dbt 2.0 parquet as base, JS…
il-dat Nov 14, 2026
e1835bb
docs: document the --info-schema and --info-schema-dir flags
il-dat Nov 14, 2026
87ad253
ci: pin the e2e job to ubuntu-24.04 (Playwright can't install chromiu…
il-dat Nov 14, 2026
9a59b0c
chore: require dbterd>=1.35 and artifact-parser>=1.1.0 (dbt 2.0 check…
il-dat Nov 14, 2026
210cbca
docs: add the sources/ artifact-source package to the repo and pipeli…
il-dat Nov 14, 2026
5e14a8f
docs: add a dbt 2.0 path to the quickstart and the info_schema keys t…
il-dat Nov 14, 2026
7ccb558
fix(sources): keep only value lineage from dbt.column_lineage (drop s…
il-dat Nov 14, 2026
10111d9
fix(sources): resolve run_results through the guarded _resolve_run_re…
il-dat Nov 14, 2026
149a301
fix(sources): warn when a JSON enrichment artifact is unreadable inst…
il-dat Nov 14, 2026
5bc1e46
fix(sources): only report a missing DuckDB when duckdb is the module …
il-dat Nov 14, 2026
cd9c522
perf(sources): read each info-schema parquet table once per build and…
il-dat Nov 14, 2026
138121a
refactor(sources): decode JSON-text columns with artifact-parser's de…
il-dat Nov 14, 2026
242d0be
refactor: pass the chosen builder into deploy so site/ no longer impo…
il-dat Nov 14, 2026
01fc168
docs: add a dbt 2.0 & Info Schema guide that walks through enabling i…
il-dat Nov 14, 2026
261ce52
chore: require dbterd>=1.35.1 so a catalog-less dbt 2.0 project build…
il-dat Nov 14, 2026
b4103f7
docs: correct quickstart step 2 — output goes to target/site and must…
il-dat Nov 14, 2026
51ef6ec
docs: add a re-recordable dbt 2.0 → dbdocs GIF to the README and the …
il-dat Nov 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 76 additions & 3 deletions .claude/design_patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ authoritative; grep it.
- [Collapsible node-page sections (`nodeSection`)](#collapsible-node-page-sections-nodesection)
- [Theory](#theory-19)
- [Example](#example-19)
- [Opt-in artifact-source plugin (info\_schema)](#opt-in-artifact-source-plugin-info_schema)
- [Theory](#theory-20)
- [Example](#example-20)

## Pipeline-stage package layout

Expand All @@ -81,7 +84,10 @@ The package is grouped by what each module does in the generate pipeline:
`extract/` (derive the documentation data from artifacts: nodes, ERDs,
node-level graph, column-level lineage) → `site/` (assemble + publish: the data
dict builder, the external gzip payload, versioned deploy, and the bundled SPA).
The CLI (`cli/`) wires user commands to `site/`. Dependencies flow one way:
`sources/` holds opt-in artifact sources (`--info-schema`) that wrap `site/`'s
`ReportBuilder` (see **Opt-in artifact-source plugin**). The CLI (`cli/`) wires user
commands to `site/`: it picks the builder with `sources.factory.builder_for` and
hands it to `site.deploy.deploy(builder=...)`, so `site/` never imports `sources/`.
`extract/` and `site/` import from `core/`, never the reverse.

### Example
Expand All @@ -101,6 +107,8 @@ from dbdocs.site.inject import strip_marker
- `dbdocs/extract/` — `nodes.py`, `erd.py`, `graph.py`, `column_lineage.py`
- `dbdocs/site/` — `builder.py`, `inject.py`, `deploy.py`, `bundle/` (the SPA:
`index.html` + `assets/{js,css,vendor,graph}/`)
- `dbdocs/sources/` — `factory.py` (`builder_for`), `info_schema/`
(`reader.py`, `synth.py`, `builder.py`)
- `frontend/` — the React Flow graph app (React+TS, Vite), built into the
committed `dbdocs/site/bundle/assets/graph/`; `src/{components,lib}`,
`test/{unit,e2e}`, `@/*`→`src/*` path alias
Expand Down Expand Up @@ -248,7 +256,11 @@ def _resolve_within_cwd(value: str, field_name: str) -> Path:
All dbt-artifact access goes through `dbdocs/core/artifacts.py`: `load_artifacts`
returns dbterd-parsed `(manifest, catalog)` with schema-version relaxation;
`adapter_type` reads the warehouse from metadata (the default sqlglot dialect).
**Critical:** `artifact_parser` aliases the `schema` field to `schema_` to
`catalog.json` is **optional** — dbt 2.0's `docs generate` doesn't write it — so
a missing file yields `catalog=None` (with a warning) and every consumer reads it
defensively (`getattr(catalog, "nodes", {}) or {}`), falling back to the manifest
per **Manifest-base columns, catalog-enriched**. Don't make a catalog-only code
path that dereferences it unguarded. **Critical:** `artifact_parser` aliases the `schema` field to `schema_` to
avoid clobbering Pydantic's `BaseModel.schema()`, so `entity.schema` is a *bound
method*, not the value. Always read `schema_`; `db_schema(entity)` centralizes
that with safe `_unknown` fallbacks. Never read `.schema` off a parsed node.
Expand Down Expand Up @@ -741,7 +753,7 @@ def _validate_segment(value: str, kind: str) -> None:
_validate_segment(version, "version")
if alias is not None:
_validate_segment(alias, "alias")
ReportBuilder(config).generate(output_dir=str(version_dir), versioned=True)
(builder or ReportBuilder(config)).generate(output_dir=str(version_dir), versioned=True)

# dbdocs/site/builder.py — generate() writes the flag into metadata
data["metadata"]["versioned"] = versioned # False by default, True from deploy()
Expand Down Expand Up @@ -1443,3 +1455,64 @@ All other renderer types follow the same open-if-non-empty / always-open-for-pri
- `dbdocs/site/bundle/assets/js/ui/ui.js` — `nodeSection`, `sectionLinkButton`, `_getSectionOpen`, `_setSectionOpen`, `_loadSectionState`, `_saveSectionState`, `expandCollapseBtn`, `focusSection`, `_forceNodeSectionOpen`, `_initSectionObserver` (scroll-spy + `sectionObserverRefresh`), `_depSection`, `_appendDepsSections`, `_physicalDetailsSection`, `_columnsSection`, `_testsSection`, `_erdSection`, `_sqlSection`, `renderPhysicalNode`, `renderCodeOnlyNode`, `renderMetricNode`, `renderSemanticModelNode`, `renderSavedQueryNode`, `renderUnitTestNode`, `renderExposureNode`
- `dbdocs/site/bundle/assets/js/service/service.js` — `columnCount`, `macroCount`
- `dbdocs/site/bundle/assets/css/style.css` — `details.node-section`, `.node-section-summary`, `.node-section-title`, `.node-section-count`, `.node-section-summary-actions`, `.section-link-btn`, `.section-in-view`, `.node-section-body`, `.expand-collapse-btn`, `.erd-section-host`, `@media print`

## Opt-in artifact-source plugin (info\_schema)

### Theory

dbt 2.0 writes a versioned parquet information schema (`target/info_schema/v1/*.parquet`,
public contract `dbt.*` + `dbt_rt.*`). `--info-schema` (or `info_schema: true`) makes it
the **base** artifact source, with any `manifest.json` / `catalog.json` /
`run_results.json` present as **enrichment**. The plugin does not add a second render
path: it synthesizes standard manifest v12 / catalog v1 / run_results v6 into a temp
staging dir and runs the **unchanged** `ReportBuilder.build_data` on it, so every
extractor, dbterd and the API tree stay untouched. `builder_for(config)`
(`dbdocs/sources/factory.py`) is the only switch: flag off returns a plain
`ReportBuilder` (same code path, same output); flag on loads
`dbdocs.sources.info_schema.builder` through `importlib.import_module`, so DuckDB stays an
optional extra (`dbdocs[info-schema]`) without an in-function import, and a
`ModuleNotFoundError` for `duckdb` (only — any other missing module re-raises)
becomes `DbDocsConfigError`. The CLI calls `builder_for` for both `generate` and
`deploy` and passes the result into `deploy(builder=...)`; `site/` never imports
`sources/`.

One merge rule, applied per record and field in `synth.py`: the parquet set decides
which records exist, a non-empty parquet value wins, and the matching JSON record fills
what parquet left empty. Column types are the exception: catalog.json type, then
`data_type_actual`, then the declared type, then `data_type_inferred` (Arrow form such as
`Int64`, weaker than a warehouse type). Staged unit-test checksums are flattened to a
string because v12 declares a string while dbt 2.0 emits an object. Parquet keeps run
history, so `build_run_results` takes the latest invocation that contains tests rather
than the last (possibly test-less) `run_results.json`.

After the base build, `columnLineage` is replaced by `dbt.column_lineage` when it has value
rows (parent to child, remapped to `{"node.col": [{node, column}]}`, deduplicated and sorted
by `(node, column)`); an empty table keeps the sqlglot result. Only **value lineage** is
kept: rows with `evolution = "scan"` (`_READ_ONLY_EVOLUTIONS` — a join, filter or grouping
key that is read but doesn't feed the column's value) are dropped, so the lineage means the
same thing as the sqlglot path's. Don't count `scan` rows as lineage. `metadata.artifact_source` is `"info_schema"`. An explicit opt-in with a
missing directory or an unsupported `dbt.project.schema_version` raises
`DbDocsConfigError` instead of silently falling back to JSON.

### Example

```python
# dbdocs/sources/factory.py
if not config.info_schema:
return ReportBuilder(config)
module = importlib.import_module(INFO_SCHEMA_BUILDER_MODULE)
return module.InfoSchemaReportBuilder(config)

# dbdocs/sources/info_schema/builder.py
staged = ReportBuilder(replace(self.config, target_dir=staging, run_results=None))
data = staged.build_data()
```

- `dbdocs/sources/factory.py` — `builder_for`
- `dbdocs/sources/info_schema/builder.py` — `InfoSchemaReportBuilder`
- `dbdocs/sources/info_schema/reader.py` — `InfoSchemaReader`
- `dbdocs/sources/info_schema/synth.py` — `build_manifest`, `build_catalog`, `build_run_results`, `column_lineage`, `_READ_ONLY_EVOLUTIONS`, `_fill`; JSON-text columns decode through artifact-parser's `decode_json_column` (one definition — don't re-add a local copy)
- `dbdocs/core/config.py` — `info_schema`, `info_schema_dir`, `info_schema_path`
- `dbdocs/cli/main.py` — `info_schema_options`, `_apply_info_schema` (on `generate` and `deploy`), `builder_for(config)` passed as `deploy(builder=...)`
- `dbdocs/site/deploy.py` — `def deploy` (`builder` parameter, default `ReportBuilder(config)`)
- `tests/fixtures/jaffle_shop_v2/` — dbt Fusion 2.0.11 `--generate-info-schema` output (parquet + manifest + run_results, no catalog)
2 changes: 1 addition & 1 deletion .github/workflows/ci_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
run: uv run pytest --cov=dbdocs --cov-report=term-missing --cov-fail-under=100

e2e:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6

Expand Down
21 changes: 13 additions & 8 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ dbt-docs/
│ ├── core/ # foundation: config, artifacts, exceptions, log
│ ├── extract/ # derive doc data from artifacts:
│ │ # nodes, erd, graph, column_lineage (sqlglot)
│ └── site/ # assemble + publish:
│ ├── builder.py # ReportBuilder — the one data dict + generate
│ ├── inject.py # strip_marker (data is external, not inlined)
│ ├── deploy.py # versioned deploy (no mike)
│ └── bundle/ # the SPA: index.html + assets/{js,css,vendor,graph}/
│ # js/ = 3-tier ES modules (data→service→ui)
│ # graph/ = committed React Flow bundle
│ ├── site/ # assemble + publish:
│ │ ├── builder.py # ReportBuilder — the one data dict + generate
│ │ ├── inject.py # strip_marker (data is external, not inlined)
│ │ ├── deploy.py # versioned deploy (no mike)
│ │ └── bundle/ # the SPA: index.html + assets/{js,css,vendor,graph}/
│ │ # js/ = 3-tier ES modules (data→service→ui)
│ │ # graph/ = committed React Flow bundle
│ └── sources/ # opt-in artifact sources wrapping ReportBuilder:
│ ├── factory.py # builder_for(config) — the one switch
│ └── info_schema/ # --info-schema: dbt 2.0 parquet → staged JSON
│ # (reader, synth, builder; DuckDB extra)
├── frontend/ # React Flow graph app (React+TS, Vite) →
│ # built into dbdocs/site/bundle/assets/graph/ (committed)
│ # src/{components,lib}, test/{unit,e2e}, @/*→src/*
Expand All @@ -51,7 +55,8 @@ dbt-docs/
```

It's a flat single-package layout — `dbdocs/` lives at the repo root (no `src/`).
The package is grouped by pipeline stage: `core/` → `extract/` → `site/`.
The package is grouped by pipeline stage: `core/` → `extract/` → `site/`, with
`sources/` as opt-in artifact sources that wrap `site/`'s `ReportBuilder`.

## Workflows

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@ Requires Python 3.10+.

```bash
dbt docs generate # writes target/manifest.json + target/catalog.json
dbdocs generate # builds ./site/ with index.html + dbdocs-data.json.gz
dbdocs generate # builds target/site/ with index.html + dbdocs-data.json.gz
dbdocs serve # static http server on http://127.0.0.1:8000
```

The site must be served over HTTP (not opened as a local file) because it fetches the data payload at load time. `dbdocs serve` handles that locally; any static host works for deployment.

### On dbt 2.0

dbt 2.0 stops writing `catalog.json` and can write a typed parquet **information schema** instead — on dbt Fusion with `--static-analysis strict`, complete with column types and dbt's own column-level lineage. dbdocs builds from either; to read the info schema, `pip install "dbdocs[info-schema]"` and set `info_schema: true` in `dbdocs.yml`:

![dbt Fusion writes the info schema, dbdocs builds and serves the site from it](docs/assets/img/dbt-2-info-schema.gif)

The [dbt 2.0 & Info Schema](https://dbdocs.datnguye.me/latest/nav/guide/dbt-2-info-schema.html) guide walks through it.

Full walkthrough, configuration, and architecture live in the **[documentation](https://dbdocs.datnguye.me/)**.

## Contributing
Expand Down
7 changes: 7 additions & 0 deletions dbdocs.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ default_version: latest
# # ship rules via the `dbdocs.health_rules` entry-point group.
# # rules_module: my_project.dbdocs_health_rules

# Opt in to dbt 2.0's parquet information schema as the base artifact source
# (needs `pip install 'dbdocs[info-schema]'`). manifest.json / catalog.json /
# run_results.json in target_dir then only enrich it. Also --info-schema on the CLI.
# info_schema: false
# Directory of the parquet files; default <target_dir>/info_schema/v1.
# info_schema_dir: target/info_schema/v1

# The pinned About link shows by default; set false to hide it.
show_about: true

Expand Down
41 changes: 36 additions & 5 deletions dbdocs/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,31 @@
from dbdocs.core.exceptions import DbDocsError
from dbdocs.core.log import logger
from dbdocs.site import deploy as deploy_module
from dbdocs.site.builder import ReportBuilder
from dbdocs.sources.factory import builder_for

__version__ = importlib.metadata.version("dbdocs")


def info_schema_options(command):
command = click.option(
"--info-schema-dir",
default=None,
help="Directory of the info-schema parquet files (default: <target_dir>/info_schema/v1).",
)(command)
return click.option(
"--info-schema/--no-info-schema",
default=None,
help="Read dbt 2.0's parquet information schema as the base artifact source.",
)(command)


def _apply_info_schema(config: DbDocsConfig, info_schema, info_schema_dir) -> None:
if info_schema is not None:
config.info_schema = info_schema
if info_schema_dir is not None:
config.info_schema_dir = info_schema_dir


# dbdocs
@click.group(
context_settings={"help_option_names": ["-h", "--help"]},
Expand All @@ -37,6 +57,7 @@ def dbdocs(ctx, config_path):


@dbdocs.command(name="generate")
@info_schema_options
@click.option("-o", "--output-dir", default=None, help="Where to write the site (default: config).")
@click.option(
"--dialect", default=None, help="SQL dialect for column lineage (default: adapter_type)."
Expand All @@ -49,14 +70,15 @@ def dbdocs(ctx, config_path):
),
)
@click.pass_obj
def generate(config: DbDocsConfig, output_dir, dialect, run_results):
def generate(config: DbDocsConfig, output_dir, dialect, run_results, info_schema, info_schema_dir):
"""Build the site from dbt artifacts (served over HTTP; data loaded externally)."""
if dialect is not None:
config.dialect = dialect
if run_results is not None:
config.run_results = run_results
_apply_info_schema(config, info_schema, info_schema_dir)
try:
ReportBuilder(config).generate(output_dir=output_dir)
builder_for(config).generate(output_dir=output_dir)
except DbDocsError as exc:
raise click.ClickException(str(exc)) from exc
# The builder already logs "Generated site at <path> (N nodes, M edges)".
Expand Down Expand Up @@ -84,15 +106,24 @@ def serve(config: DbDocsConfig, port):
"--delete", "delete", is_flag=True, default=False, help="Delete this version instead."
)
@click.option("--push/--no-push", default=False, help="Publish to the gh-pages branch.")
@info_schema_options
@click.pass_obj
def deploy(config: DbDocsConfig, version, alias, title, delete, push):
def deploy(config: DbDocsConfig, version, alias, title, delete, push, info_schema, info_schema_dir):
"""Generate a versioned build and update the version index (or --delete one)."""
_apply_info_schema(config, info_schema, info_schema_dir)
try:
if delete:
deploy_module.delete(config, version=version, push=push)
click.echo(f"Deleted version {version}")
return
out = deploy_module.deploy(config, version=version, alias=alias, push=push, title=title)
out = deploy_module.deploy(
config,
version=version,
alias=alias,
push=push,
title=title,
builder=builder_for(config),
)
except DbDocsError as exc:
raise click.ClickException(str(exc)) from exc
click.echo(f"Deployed version {version} into {out}")
17 changes: 16 additions & 1 deletion dbdocs/core/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

from dbterd.helpers import file

from dbdocs.core.log import logger

#: Bucket label used when a node/source has no database or schema set.
UNKNOWN = "_unknown"

Expand Down Expand Up @@ -54,10 +56,23 @@ def artifact_version(target_path: str, artifact: str) -> "int | None":


def load_artifacts(target_path: str) -> "tuple[Any, Any]":
"""Return the dbterd-parsed ``(manifest, catalog)`` for a dbt target dir."""
"""Return the dbterd-parsed ``(manifest, catalog)`` for a dbt target dir.

``catalog.json`` is optional (dbt 2.0's ``docs generate`` does not write it):
when absent, ``catalog`` is ``None`` and every consumer falls back to the
manifest — columns lose their warehouse type and column-level lineage can't
resolve ``SELECT *`` / unqualified columns.
"""
manifest = file.read_manifest(
path=target_path, version=artifact_version(target_path, "manifest")
)
if not (Path(target_path) / "catalog.json").is_file():
logger.warning(
"No catalog.json in %s — building from the manifest only "
"(no warehouse column types; reduced column-level lineage).",
target_path,
)
return manifest, None
catalog = file.read_catalog(path=target_path, version=artifact_version(target_path, "catalog"))
return manifest, catalog

Expand Down
16 changes: 16 additions & 0 deletions dbdocs/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ class DbDocsConfig:
#: dotted import path whose ``register_rule`` calls add custom rules). Entry
#: points under ``dbdocs.health_rules`` are also discovered automatically.
health: dict = field(default_factory=dict)
#: Opt in to reading dbt 2.0's parquet information schema as the base artifact
#: source (``manifest.json`` / ``catalog.json`` / ``run_results.json`` in
#: ``target_dir`` then only enrich it). Needs ``dbdocs[info-schema]``.
info_schema: bool = False
#: Directory holding the information-schema parquet files; ``None`` ⇒
#: ``<target_dir>/info_schema/v1``.
info_schema_dir: "str | None" = None
#: The pinned About link shows by default; set false to hide it.
show_about: bool = True
#: Links rendered on the About page as external CTA buttons. Each entry is a
Expand Down Expand Up @@ -129,6 +136,8 @@ def load(cls, path: "str | Path | None" = None) -> "DbDocsConfig":
"favicon",
"run_results",
"health",
"info_schema",
"info_schema_dir",
)

def render_context(self) -> dict:
Expand Down Expand Up @@ -164,3 +173,10 @@ def output_path(self) -> str:
A relative path that would escape the cwd raises ``DbDocsConfigError``.
"""
return str(_resolve_within_cwd(self.output_dir, "output_dir"))

@property
def info_schema_path(self) -> str:
"""Directory of the information-schema parquet files (see ``info_schema_dir``)."""
if self.info_schema_dir:
return str(_resolve_within_cwd(self.info_schema_dir, "info_schema_dir"))
return str(Path(self.target_path) / "info_schema" / "v1")
Loading
Loading