Amortize // Consolidation ledger
commerce.orders · fixture 01
DataHub-aware SQL reuse

Pay for one model, not four copies.

Amortize finds exact repeated first-CTE bodies in a DataHub query workload, writes one dbt model, rewrites every matching consumer, and proves the results stay identical.

Interactive consolidation

Five queries enter the ledger.

Four share fingerprint 2c12a4cd…. Select any ribbon to inspect it, then collapse the repeated group.

Generated dbt model

int_orders_reuse_2c12a4cd

orders + customers + refunds → reusable completed-order facts
exact normalized AST match
7 projected columns
4 rewritten consumers
Selected query

Net revenue by segment

Shares the repeated customer_order_facts CTE and is included in the consolidation group.

DuckDB execution proof

Four rewrites. Four exact matches.

Each original and rewritten query ran against the included warehouse fixture. SHA-256 covers ordered columns plus lexicographically sorted JSON rows.

ConsumerRowsOriginal = rewrite SHA-256Result
Verification status4 / 4 identical · PASSED
Exact grouping onlySQLGlot normalizes DuckDB SQL; clustering requires an exact first-CTE abstract-syntax-tree match.
Unrelated query preservedCustomer count has a different shape and is excluded rather than force-fit.
Writeback prepared onlyLineage and documentation payloads exist as review artifacts. Nothing was sent to DataHub.

What this proves

The recorded five-query workload produces one four-query cluster, one executable model, four rewritten consumers, and four identical result hashes in DuckDB.

Recorded boundary

This public proof uses captured DataHub-shaped catalog context and a local warehouse fixture. It does not claim a live tenant session, production cost savings, or an applied graph write.

Reproduce locally

Audit every entry

Repository: REPOSITORY_URL_PENDING_PUBLICATION
  1. Clone the public Apache-2.0 repository.
  2. Run python -m venv .venv && .venv/bin/pip install -e '.[dev]'.
  3. Run .venv/bin/pytest -q.
  4. Run ./scripts/demo.sh, then inspect examples/sample-output/evidence_manifest.json.