Skip to content

Lightdash metrics in the generated dbt project, and release 1.14.0 - #48

Merged
jarichb merged 7 commits into
mainfrom
claude/lightdash-export
Oct 7, 2026
Merged

jarichb merged 7 commits into
mainfrom
claude/lightdash-export

Conversation

@jarichb

@jarichb jarichb commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Adds a Lightdash exporter beside the Ossie one, so a metrics file reaches Lightdash too.

What changes

  • generate --lightdash writes the model's metrics, dimensions and joins into the generated dbt project:
    • Where: under config.meta of each staging model's own models/staging/stg_<table>.yml. The meta is merged in next to the tests, because dbt reads a model's properties from one file only.
    • Which metrics: the --metrics file's, or without one the metrics the model implies.
  • model2data metrics export --to lightdash writes the same meta as one properties file, without generating.
  • Python API: model2data.metrics.to_lightdash and write_lightdash, beside to_ossie.

Mapping. Format chosen: the dbt YAML meta that Lightdash documents as its default for dbt projects. Its MetricFlow support is beta, and Lightdash YAML is for projects without dbt.

  • Joins: each table is joined many-to-one to every table it reaches along exactly one path.
  • Metrics:
    • simple metrics sit on their column;
    • row counts are count_distinct of a one-column primary key;
    • ratios and expressions are type: number metrics over ${input}.
  • Text fields: ai_context becomes ai_hint. percent and currency become '0.00%' and '#,##0.00'.
  • Filters:
    • they become filters wherever Lightdash's filter grammar means exactly the same, checked against its source, not only the docs;
    • a not-equal gets '!null' beside it, since Lightdash's lets nulls through;
    • an any group or a date comparison becomes a CASE WHEN in sql, so the metric counts what its known value counts.
  • Lossiness: what Lightdash has no place for is listed in the run's summary, the same way as Ossie. That covers an enum's members, a table's role and grain, a currency, a metric dated through another table, and a ratio whose inputs sit on two tables, which is left out.

Docs: https://docs.lightdash.com/references/metrics, /references/tables, /references/dimensions, /references/writing-descriptions, /integrations/dbt/metricflow.

Checked

  • The full suite passes: 2175 tests. ruff, ruff format and ty are clean, and lightdash.py has 100% coverage.
  • Every example's output validates against Lightdash's published JSON Schema for dbt YAML (lightdash-dbt-2.0.json, MIT, vendored with its licence).
  • With dbt-core 1.12.3 and dbt-duckdb 1.11.0, dbt parse is clean and dbt build of the coffee example passes (79/79).
  • @lightdash/cli 2.177.0 lightdash compile --no-partial-compilation succeeds for every explore. The test runs only when lightdash is on PATH, so CI skips it.
  • Byte-identical without --lightdash: I diffed origin/main against this branch on three runs: with metrics, with --days 2 --defects messy, and with --unit-tests.

Not done

  • No live deploy to a Lightdash instance. Lightdash can't open a local DuckDB file, so that needs Postgres or MotherDuck.
  • dbt 1.11, the CI floor, wasn't run locally; CI covers it.

Release

  • CHANGELOG 1.14.0, pyproject.toml 1.14.0 and the lock.
  • After merge, draft the v1.14.0 release; publishing it uploads to PyPI.

🤖 Generated with Claude Code

jarichb and others added 6 commits October 6, 2026 22:49
to_lightdash(semantic) writes the dbt model properties Lightdash reads
(config.meta): joins along every path that is the only one, dimensions
labelled and other columns hidden, simple metrics and row counts on
their columns with filters in Lightdash's own grammar or a CASE WHEN
where it cannot say them, ratios and derived metrics as type: number.
What Lightdash has no place for is listed in the export's lossiness.
write_lightdash merges it into a generated project's staging YAML.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ightdash compile

Every mapping and every loss has a unit test; every example's document
validates against Lightdash's own JSON Schema for dbt YAML (vendored,
MIT); the shipped examples with --lightdash must dbt parse cleanly and,
when the Lightdash CLI is on PATH, compile every explore with
--no-partial-compilation. Also writes '!null' once when ne and
is_null: false both ask for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jarichb
jarichb merged commit b93cff1 into main Oct 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant