Semantic Layers & Metrics
Cube, dbt Semantic Layer, MetricFlow — define metrics once, query them everywhere.
A semantic layer turns "revenue last quarter, by region, excluding test accounts" into a single API. Without one, the same metric drifts across BI & Dashboards, Embedded Analytics, and ML features. With one, every consumer hits the same definition.
Open / open-core semantic layers
- ★ Cube (cube.dev) — the dominant OSS pick. YAML / JS metric definitions; pre-aggregations; REST / GraphQL / SQL API; row-level security. Apache 2.0 core; paid Cube Cloud. Default for embedded analytics use cases.
- ★ dbt Semantic Layer (powered by MetricFlow) — define metrics in dbt YAML; query via JDBC / GraphQL / Python. dbt-core + MetricFlow are open source (BSL → Apache 2.0 transitions); dbt Cloud's hosted Semantic Layer is paid. Default if your team already lives in dbt.
- MetricFlow (Transform → dbt Labs) — the engine inside the dbt Semantic Layer; usable standalone via
pip install metricflowfor warehouse-side metric queries. - GoodData.CN — open-core semantic layer + visualization SDK; community edition is free.
- Lightdash metrics — dbt-native metrics surfaced through a BI UI; see BI & Dashboards.
Closed / paid semantic layers
- Looker / LookML — the original; Google-owned; expensive but battle-tested at large enterprises.
- AtScale, Kyligence, dbt Cloud Semantic Layer — paid offerings.
- Sisense, ThoughtSpot, Tableau (with calculated fields) — embed semantic-layer-ish features inside the BI tool.
Headless BI patterns
- Cube + Recharts/Tremor — the canonical OSS embedded analytics stack; see Embedded Analytics.
- MetricFlow + Streamlit / Marimo / Evidence — small teams; see Data Apps and BI & Dashboards.
- Cube → ChatGPT / LLM — semantic layers are increasingly the "right shape" for LLM-driven analytics; the metric definitions become the function spec the model calls.
Metric stores adjacent
- Feast (feature store) — features ≈ metrics for ML; Apache 2.0; pairs with online + offline stores. See also AI/LLM.
- Hopsworks Feature Store — open-core feature store.
- Tecton — paid; managed feature platform.
Patterns to adopt
- One metric, one definition. "MRR" gets a single SQL formula in your semantic layer; everything else queries it.
- Pre-aggregations. Cube's pre-aggs / dbt incremental rollups; cuts warehouse spend dramatically for repeated dashboard queries.
- Row-level security in the layer.
tenant_id/regionfilters from the JWT, not from each chart. - Versioned metrics. Metric definitions live in Git; PR review like code; CI runs against historical data to catch breaking changes.
- Don't reinvent dimensions. Date, customer, region — define them in one semantic-layer model; reuse across metrics.
- Expose to LLMs deliberately. Metric definitions are perfect tool specs; gate per-tenant access via the layer's auth.
Pick this if…
- Default OSS for embedded analytics: Cube.
- Default for dbt-shaped data teams: dbt Semantic Layer (MetricFlow).
- You want metrics + a BI UI in one: Lightdash.
- You're already on Looker: stay; LookML is a semantic layer, just paid.
- LLM-driven Q&A on your data: Cube or MetricFlow as the function-call surface for the model.
- Feature store for ML, not BI: Feast.