The dbt Semantic Layer is a centralised business logic layer that defines metrics and dimensions once in code, making them consistently available across all downstream tools — BI platforms, notebooks, and APIs — without replicating business logic in each consumer. Before the Semantic Layer, 'economy rate' might be defined differently in a Looker dashboard, a Python notebook, and a Slack bot — producing different numbers from the same data. The Semantic Layer enforces a single authoritative definition for every metric.
dbt's Semantic Layer is built on MetricFlow — an open-source semantic framework that dbt acquired and integrated in 2023. MetricFlow defines metrics in YAML configuration files alongside dbt models, expressing them as measure aggregations (SUM, COUNT, AVERAGE, RATIO) over semantic model entities, dimensions, and time grains. When a BI tool queries the Semantic Layer, MetricFlow generates the SQL needed to compute the metric at the requested grain and time period, choosing the most efficient dbt model to query — whether a summary mart or the underlying fact table.
Analogy🏏Cricket
🏏 Think of it like cricket: OLTP is the IPL's live ticketing counter — it handles thousands of simultaneous seat reservations, each requiring a precise single-seat record update with immediate confirmation. Speed per transaction and data consistency under concurrent updates are everything. OLAP is the IPL's season statistics department — it runs complex analytical queries across every ball bowled in every match of every season to produce the published rankings, economy rates, and historical comparisons. No one books a seat through the statistics department, and no broadcaster calls the ticketing counter for Bumrah's career economy rate. The two workloads demand completely different systems. Just as the ticketing counter is built for speed and correctness on one seat at a time and would buckle if asked to tally a decade of attendance mid-sale, an OLTP row-store excels at single-record writes but chokes on full-table aggregation; and just as the statistics department pores over millions of past deliveries but would be hopeless at booking a live seat under contention, the OLAP columnar engine sweeps billions of rows yet is the wrong tool for a fast single-row update. The physical design of each — row-oriented for the counter, columnar for the stats desk — is what makes it superb at its own job and unfit for the other's.
🏏 Showing the Cricket analogy — a Cricket version isn’t available for this concept yet.