Skip to content

Elementary

Elementary is a dbt package that layers automated test logging, anomaly detection, and schema-change tracking on top of the dbt project. It runs entirely inside dbt — no separate service to deploy — and writes its results into a dedicated ${ENV}__elementary schema in ClickHouse.

  • A persistent log of every dbt test run (dbt_test_results, elementary_test_results)
  • Anomaly tests that flag deviations the static dbt tests would miss
  • Schema-change detection that flags column adds, drops, and type changes
  • A standalone HTML report (edr report) for review outside the dbt CLI
FieldValue
Packageelementary-data/elementary (in dbt/dependencies.yml)
Schema${ENV}__elementary (e.g. dev__elementary, main__elementary)
Project-specific viewsdbt/models/elementary_extensions/ (daily_test_summary, run_results_by_date, test_results_by_date)

After bumping the package or recreating an environment, build the elementary infrastructure tables:

Terminal window
uv run dbt run --select elementary

Elementary intentionally ignores --full-refresh; to recreate its tables from scratch, set the Elementary-owned variable instead:

Terminal window
uv run dbt run --select elementary --vars "elementary_full_refresh: true"

Add the Elementary tests in the model’s properties.yml alongside the standard dbt tests:

models:
- name: matches
config:
elementary:
timestamp_column: event_date
tests:
- elementary.volume_anomalies:
timestamp_column: event_date
- elementary.schema_changes

Available test types:

TestDetects
volume_anomaliesRow-count drops or spikes vs. historical volume
freshness_anomaliesTables that haven’t been written to recently
column_anomaliesPer-column null %, distinct count, min/max drift
dimension_anomaliesDistribution shifts within categorical columns
schema_changesColumn additions, removals, type changes

Test runs write to the ${ENV}__elementary schema:

  • dbt_test_results — every dbt test execution
  • elementary_test_results — Elementary anomaly tests specifically
  • alerts_* views — failed-test summaries grouped for downstream alerting

The project-specific views in dbt/models/elementary_extensions/ (daily_test_summary, run_results_by_date, test_results_by_date) sit on top of these and are the easiest entry points for ad-hoc queries.

Outside the dbt CLI, the edr tool generates an HTML report:

Terminal window
pip install 'elementary-data[clickhouse]'
edr report --profile elementary

The elementary dbt profile lives alongside the main clickhouse profile in the same profiles.yml.

  • dbt: Elementary runs as a dbt package — every dbt build populates its tables
  • ClickHouse: the only target — Elementary writes to ${ENV}__elementary
  • Airflow: since Elementary tests run as part of dbt build, the daily Airflow runs continuously refresh the test history