Menu ▾ ▴

#72 fix(dbt): make erp_sources authoritative; default to d365_fo

closed
nobody
None
2026-06-21
2026-06-19
Anonymous
No

Originally created by: grynn-in

Fixes [#60].

Problem

A fresh deploy ships D365-only demo data, but erp_sources defaulted to [d365_fo, erpnext]. The stg_erpnext__* models ran against epm_raw tables that were never loaded and errored; because the canonical models UNION over erp_sources, those 7 failures cascaded into 169 skipped downstream models — including gold_trial_balance, the actuals fact the Excel =EPM() API reads.

Fix

Make erp_sources the single source of truth for which ERPs are active:

  • Default it to [d365_fo] (matches the shipped demo).
  • Gate each per-ERP staging subtree with +enabled keyed on membership in erp_sources, so a fresh dbt build never builds staging for an ERP whose raw tables aren't present. Enablement and the canonical UNION now read the same var, so they can't drift.

ERPNext deployments opt in:

dbt build --vars '{erp_sources: [d365_fo, erpnext]}'

Verification (bare dbt build, no flags — what deploy.sh runs)

before after
result PASS=73 ERROR=7 SKIP=169 PASS=190 ERROR=4 SKIP=42
gold_trial_balance not built 58 rows
stg_erpnext__* tables 7 errors 0 (cleanly disabled)

The remaining 4 errors are pre-existing, unrelated test issues tracked in [#70].

Related

Tickets: #60
Tickets: #70

Discussion

  • Anonymous

    Anonymous - 2026-06-19

    Originally posted by: grynn-in

    Independent review — APPROVE WITH NITS

    Mechanism is correct: +enabled: "{{ 'erpnext' in var('erp_sources', ['d365_fo']) }}" resolves at parse time (dbt coerces the rendered True/False to bool for enabled), and because the canonical models loop over the same var('erp_sources', ['d365_fo']), enablement and the UNION can't drift — no "depends on a disabled node" error for [d365_fo], [erpnext], or [d365_fo, erpnext] in the canonical layer. Default-change blast radius is clean: every reader uses the explicit ['d365_fo'] default.

    One real nit to document before merge: the bronze/ layer refs stg_d365_fo__* models directly (not via the erp_sources loop) — ~11 models, e.g. bronze_general_journal_entries → ref('stg_d365_fo__gl_journal_entries'). So erp_sources=[erpnext] (D365 excluded) would disable those staging models while bronze still hard-refs them → parse error. This is not a problem for the PR's goal (d365_fo is the default and D365 is the only single-switch target), but it means erp_sources is really "D365 mandatory, ERPNext optional", not a symmetric switch. Suggest a one-line note in the erp_sources comment that d365_fo must remain present (bronze depends on it directly).

    Verified separately: bare dbt build PASS 73→190, 0 stg_erpnext tables, gold_trial_balance builds.

     
  • Anonymous

    Anonymous - 2026-06-19

    Ticket changed by: grynn-in

    • status: open --> closed
     

Log in to post a comment.