Design decisions
Why it's built this way
The five choices that shape the project, written as architecture decision records: what forced the decision, what was decided, and what it costs.
ADR 0001 · Accepted · 2026-10-14
Right-size the engine: Python notebooks for the daily load
Context. The workload is small: about 30k worklog rows a quarter, a few hundred users, a few thousand CRM rows. Fabric offers Spark notebooks and Python notebooks; Python notebooks run a single-node kernel with deltalake, DuckDB, pandas and pyarrow preinstalled. The project also had to run on a Windows laptop with no Java, Docker or WSL, so a reviewer can clone it and see the tables.
Decision. Every notebook in the daily pipelines is a Fabric Python notebook. Transformations are DuckDB SQL over Arrow; reads and writes go through delta-rs, including MERGE for SCD2. A local runner executes the same notebook files with a stand-in for notebookutils.
Consequences.
- Sessions start in seconds and use a fraction of the capacity units a Spark pool would. That matters on an F2/F4 capacity shared with reports.
- The Python path runs on the laptop, in CI and in Fabric; the Spark path runs in CI and Fabric.
- The SQL is close to Spark SQL, and ADR 0004 carries the core logic over to PySpark, proven identical in CI.
- Spark tuning for the Spark path (month partitioning, OPTIMIZE with Z-ORDER and V-Order, VACUUM) lives in nb_spark_maintenance and is checked in CI.
ADR 0002 · Accepted · 2026-10-14
Recompute silver worklogs with the person-day rule
Context. Both time sources let people edit and delete entries long after the work date. The APIs only answer "what changed since X", and can't report a day whose entries were all deleted, because nothing is left to return. A classic incremental MERGE on entry ID handles edits but not deletions, and its result depends on the order and batching of past runs.
Decision. Extracts are complete person-days: incremental extracts carry every changed person-day in full, and the monthly full extract covers a date window. Silver is recomputed from bronze on every run with one rule: for each person-day, keep the rows of the latest extract that contains it, unless a later full extract covers that date without it. The result is written in one atomic overwrite.
Consequences.
- Edits and partial deletions are handled by the daily run. A whole deleted day disappears at the next monthly full run: the only gap, documented and tested.
- Silver is a pure function of bronze, so replaying the landing archive in any batching gives the same table, and a backfill is just another full extract.
- Recomputing takes about a second at this volume. Past a few million rows, restrict it to the person-days a run touched and apply it with MERGE, using the same rule.
ADR 0003 · Accepted · 2026-10-14
A public adaptation on synthetic sources
Context. The problems this project solves come from a production platform I built on Microsoft Fabric: consolidating worklogs from two systems, resolving identities across domains and logins, keeping finance-facing keys stable, and comparing sold with logged hours. That work, its code and its data belong to an employer, and this project is public.
Decision. Adapt the platform for a fictional company with synthetic, deterministic sources. The generator reproduces the kinds of source behaviour that make the problem hard: blank emails for deactivated users, mixed timestamp formats, legacy and external domains, swapped logins, namesakes, overlapping API pages, late logging, edits and deletions. No name, identifier, client or number from the original is kept.
Consequences.
- The project can be public, and anyone can run it end to end.
- The generator doubles as a test fixture: every quirk exists on purpose, on fixed people, so tests can assert how each one is handled.
- The story of what went wrong in production lives in this case study, in general terms.
ADR 0004 · Accepted · 2026-10-14
A Spark path, proven identical in CI
Context. ADR 0001 chose Python notebooks because the volume doesn't need a cluster. That stays true, but most Fabric teams run Spark, and "the SQL ports to Spark" is worth more shown than said.
Decision. Port the parts with real logic to PySpark and Spark SQL as Fabric Spark notebooks: the person-day rule, the SCD2 history with the Delta Lake MERGE API and the identity map, and the ranked matching rules. They read the same bronze tables and write spark_* tables, and nb_parity compares each one with its Python counterpart in both directions and fails on any difference. In CI, a job with Java 17, Spark 3.5 and Delta 3.2 (the Fabric Runtime 1.3 versions) runs the whole sequence over five runs and requires zero differences.
Consequences.
- Switching engines later is a cut-over, not a rewrite: run both, compare, switch.
- Dimensions, marts and the project registry stay on the primary path, so the shadow fact points at the same keys and can be compared row by row.
- Porting changed the syntax, not the logic: distinct on and qualify became window functions, and timestamp parsing moved to to_timestamp with unparseable values as NULL.
- Day-to-day development stays on the fast Python path; the parity job runs the Spark notebooks on every push and pull request.
ADR 0005 · Accepted · 2026-10-14
The semantic model as code, every measure checked against the lakehouse
Context. A medallion ends where people read it: a Power BI model. Models built by hand drift from the tables under them, and a subtly wrong DAX measure looks just as convincing in a report as a right one. Direct Lake only runs against a Fabric capacity, so the model can't be queried on a laptop as-is.
Decision. Define the model once: friendly tables over the gold tables, relationships, and every measure with a description, format string and display folder. Generate it as Direct Lake TMDL (the deployable item) and as an Import copy over Parquet exports of the same tables. Load the Import copy into Power BI Desktop with pbi-cli, run every measure as a DAX query, and compare each result with the same number computed independently in DuckDB. In CI, every field a report visual uses must exist in the model.
Consequences.
- The deployed model and the tested model can only differ in storage mode; a test fails if the committed TMDL drifts from its definition.
- 190 values across all 26 measures match DuckDB, by month, by account and in total, including time intelligence and coverage.
- Utilization and sold-vs-logged are plain aggregations because the gold layer has a capacity table (person × working day) and a conformed account dimension.