Skill: design-medallion-lakehouse
Invoked by:
lakehouse-architect(primary). Consulted bydatabricks-platform-engineerfor the layer/table contract the code must honor.When to invoke: "how should we structure this on Databricks?"; "bronze/silver/gold + how to lay out the Delta tables"; "batch, streaming, Auto Loader, or DLT?"; "how do we set up Unity Catalog?"; "what compute and what will it cost?"
Output: a medallion design + per-layer Delta table strategy + batch-vs-streaming call + Unity Catalog governance layout + compute/DBU cost envelope, captured in the lakehouse design template.
Procedure
- Start from the reader and the SLO, not the tool. Who queries this, at what shape, and how fresh must it be? Write those down first — the whole design flows from them. Traverse
../../knowledge/databricks-decision-tree.md. - Run the batch-vs-streaming gate (Tree 1). Default to a scheduled batch job. Only choose Auto Loader (files landing), Structured Streaming (continuous events), or DLT (declarative managed) when a real sub-hour SLO forces it — and name the checkpoint/trigger/exactly-once implication when you do.
- Layer with the medallion pattern (Tree 2). Bronze = raw, append-only, replayable. Silver = conformed, deduped, validated, typed. Gold = serving tables shaped to the reader. Justify each layer by what it earns; don't collapse a replay-valuable hop, don't add a gold table no one reads.
- Design each Delta table for its queries (Tree 3). Partition only on a low-cardinality column that filters real queries — or use liquid clustering (verify GA/behavior at use). Never partition on a high-cardinality column (small-file explosion). Name file-size target,
OPTIMIZE/Z-ORDER/VACUUMcadence, and the write pattern (MERGE/upsert/CDC vs append vs overwrite). - Lay out Unity Catalog governance from the start. Catalog-per-env or per-domain, schema boundaries, managed vs external tables/volumes, grants to groups not users, lineage/audit, and PII tagging. Retrofitting governance is expensive.
- Set the compute & DBU envelope (Tree 5). Jobs compute for jobs, serverless/right-sized SQL warehouse for BI, Photon where it pays. Autoscaling bounds + spot + auto-termination. Give an order-of-magnitude DBU estimate and name the top cost drivers. Mark all pricing verify-at-use + dated.
- State the seams and flip conditions. dbt gold modeling →
analytics-engineering; external orchestration →data-orchestration; org privacy policy →data-governance-privacy; ML lifecycle →ml-engineering; Fabric/OneLake →microsoft-fabric. Name the 1-2 facts that would flip each call.
Worked example
User: "We get order events from Kafka and want a dashboard of daily revenue by region, plus the raw data kept for audits. Build it on Databricks."
- Reader & SLO: BI dashboard, refreshed daily is fine; audit needs raw retained. No sub-hour requirement.
- Batch-vs-streaming (Tree 1): despite the Kafka source, the SLO is daily → a scheduled batch read (or
Trigger.AvailableNowstream-once) is cheaper than an always-on stream. Don't reflex "streaming" from "Kafka." - Layering (Tree 2): Bronze = raw Kafka payloads appended (the audit anchor). Silver = parsed, deduped, typed orders (MERGE on order_id). Gold =
daily_revenue_by_regionaggregate shaped for the dashboard. - Table design (Tree 3): silver partitioned by
order_date(low-cardinality, filters queries); not byorder_id(high-cardinality → tiny files).OPTIMIZE/Z-ORDER (region)nightly;VACUUMat safe retention. Gold overwritten daily. - Unity Catalog:
prod.orderscatalog/schema; grants to the analytics group; PII (customer id) tagged and masked in gold. - Compute/DBU: a small jobs-compute cluster on a nightly schedule with auto-termination; a right-sized SQL warehouse (auto-stop) for the dashboard; Photon on for the SQL aggregate. Top cost risk: leaving the warehouse always-on. (DBU figures verify-at-use.)
- Seams: if analysts want to model the gold layer in dbt →
analytics-engineering.
Guardrails
- Batch is the default — streaming is earned by a real sub-hour SLO, not the word "real-time."
- Never over-partition — a high-cardinality partition column is the most common self-inflicted small-file wound.
- Governance is designed in, not bolted on — Unity Catalog layout + grants-to-groups + PII tagging from the start.
- Auto-terminate all compute — idle clusters/warehouses are the top DBU leak.
- Every runtime/feature/pricing fact carries a retrieval date + verify-at-use — DBR versions, liquid clustering/predictive-optimization GA, and DBU pricing move. See
../../knowledge/databricks-patterns-2026.md. - The design is the architect's; the code, dbt modeling, org policy, and ML lifecycle leave this skill — route to
databricks-platform-engineer/analytics-engineering/data-governance-privacy/ml-engineering.