Lesson 14 Cost & Governance
Theme:

Homework 14 — Cost & Governance

Lesson 14 · Data Engineering with Python · 3 exercises

All three tasks build on the governance/ tree added in Lesson 14. Task 1 is a SQL cost-reporting exercise. Task 2 involves extending grants.yml with a new role. Task 3 is a GDPR audit-log exercise for a declined (not approved) erasure request.

Task 1 — Detect the most expensive team last week

Write a single query that returns the one team with the highest cost in the last 7 days. Use the DuckDB _query_costs table (local) or SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY (Snowflake, optional).

The result must be a single row with at least two columns: team and a cost column.

Self-check:

Task 2 — Add a new role to grants.yml

Define a data_scientist role in governance/grants.yml with read-only (SELECT) access to fact_events AND read-only access to a hypothetical feature_store table. Reuse the existing YAML structure exactly — same indentation, same key names, same list syntax.

Self-check:

Task 3 — Audit-log a declined deletion request

Write a .jsonl entry for a GDPR erasure request that you decline. Invent a fictional public-figure account whose data falls under a journalistic exemption (GDPR Article 85). The entry must include these fields: ts, action: "gdpr_decline", subject, reason, legal_basis.

Append the entry to governance/gdpr/deletion_log.jsonl (do not replace the file; use open(..., 'a')).

Self-check:

View solutions →