Data Analyst / Engineer · Projects

Project 2: A warehouse with personal data protected

Marking guide version 1 · Lessons: DT5 lessons 2 and 5, DT6 lessons 1–5, DT7 lessons 1–5, DT10 lesson 3

The problem and who it's for

SabziSathi's dbt project builds, but it passes customers' names, phone numbers and emails into the marts, keys customers by an unsalted MD5 of their phone number, gives every order the area from the September export even after customers moved, counts cancelled and refunded lines as revenue, has no tests or freshness checks, and is almost undocumented. The analysts who use it can't tell which numbers to trust, and any one of them can read every customer's phone number.

Scope

Not included

Before you start

Starter files

Download everything at once: starter/data-starter.zip.

Milestones

  1. Run pytest tests/test_warehouse.py and note which of the 10 tests fail and why.
  2. Fix staging and the customer key (tests 3 and 4).
  3. Build the area history and join it on the order time (test 6).
  4. Fix the measures and marts (test 7), and add tests and the reconciliation (test 2).
  5. Add sources with freshness, the incremental fact and descriptions (tests 8 to 10).
  6. Run all 10 tests twice in a row.

Expected outputs

Acceptance tests

# Input Expected result
1 pytest tests/test_warehouse.py 10 of 10 pass, twice in a row
2 dbt build --profiles-dir . with SABZI_KEY_SALT set Every model and test passes (test 1)
3 Every column and value in the marts schema No name, phone or email; customer keys are 64-character salted hashes (tests 3 and 4)
4 marts.dim_customer_area_history and marts.fct_order_lines 640 history rows, 600 current; 10,181 lines, each with an area its store serves (tests 2 and 6)
5 marts.mart_daily_sales 3,411 orders, 2,918 delivered, 196,576,400 paise net revenue (test 7)
6 Reload 30 October and rebuild The same 10,181 lines and net revenue (test 9)

Failure and recovery exercises

  1. Write the salt into dbt_project.yml as a variable and run test 4. Explain the failure, then move it back to the environment.
  2. Join the fact to the history on the customer key only and count the rows. Explain the difference, then restore the time condition.
  3. Remove unique_key from the incremental fact, reload a day and rebuild. Describe what happens to the totals, then restore it.

Evidence to submit

Marking guide and self-check

Pass rule: every Safety-critical (S) and Mandatory (M) item must be met. A single unmet safety item means the project is not complete, whatever else is done. Quality items are for your own improvement.

Your answers are saved in this browser on this device. Self-checked means you checked your own work against this guide; it is not a reviewer's approval. Never paste passwords, keys, tokens or real customer data here.

Checklist (marking guide version 1)
Evidence

← PreviousA pipeline you can trust
ProLearners Assist