hyperlakeDiscuss a deployment ↗
Blog · · 5 min read

dbt Semantic Layer and MetricFlow Architecture

The dbt Semantic Layer uses MetricFlow to define metrics once, generate consistent SQL, and serve trusted logic to dashboards, apps, and AI agents.

Video thumbnail: dbt Semantic Layer and MetricFlow Architecture
Watch: dbt Semantic Layer and MetricFlow Architecture (1:58) · Video page

The dbt Semantic Layer is a centralized, code-defined layer for business metrics. Powered by MetricFlow, it models entities, measures, dimensions, relationships, and time rules, then translates metric requests into SQL. Dashboards, analytical applications, natural-language interfaces, and agents can therefore use the same governed calculation logic.

This architecture matters because independently written calculations can make the same metric produce conflicting results across departments and tools. Central definitions give data teams a controlled place to review, test, audit, and change important business logic. The video above walks through the core ideas.

What problem does the dbt Semantic Layer solve?

The dbt Semantic Layer addresses metric drift: the gradual divergence of business calculations as teams recreate them in separate SQL queries, dashboards, and applications. It establishes a shared definition that multiple consumers can use instead of maintaining their own versions.

Without a semantic layer, two departments may both report monthly revenue while applying different date fields, filters, aggregation rules, or treatment of adjustments. The dashboards may look correct individually, but their results cannot be reconciled without examining each implementation.

A centralized metric architecture changes the ownership model. Business concepts become governed data assets rather than calculations embedded inside individual reports. This supports:

  • Consistent metrics across dashboards, reports, and analytical applications.
  • Clear review processes for changes to business logic.
  • Reuse of approved dimensions, measures, and relationships.
  • Better traceability when teams need to understand how a result was calculated.

The goal is not merely to store calculation names. It is to give every consuming system the same executable analytical meaning. This principle is explored more broadly in semantic layer architecture.

Diagram: Independent SQL creates metric drift, while a semantic layer gives consumers shared governed definitions.
Central definitions replace duplicated calculations with reusable analytical logic.

How does MetricFlow generate SQL from metric requests?

MetricFlow acts as the semantic query engine behind the dbt Semantic Layer. It receives a request for a metric and uses centrally defined entities, measures, dimensions, relationships, and time rules to construct the required SQL.

For a request such as monthly revenue, the process works conceptually as follows:

  1. A user, dashboard, application, or agent requests the metric with relevant dimensions and a time range.
  2. MetricFlow resolves the approved metric definition and identifies the required measures, entities, and relationships.
  3. It determines how the underlying data must be joined, filtered, grouped, and aggregated.
  4. It generates SQL for execution against the relevant analytical data system and returns the result to the requesting tool.

This separation is important. Consumers ask for a business concept rather than reimplementing its calculation. MetricFlow handles the translation from semantic intent to a query based on the definitions maintained by the data team.

The semantic layer does not eliminate the need for well-modeled, reliable source data. It provides a consistent interface over that data so downstream tools do not each have to understand every table, join path, and calculation rule.

Diagram: MetricFlow resolves a metric request against semantic definitions, generates SQL, and returns the result.
MetricFlow translates a business-level request into SQL using approved semantic rules.

Why should metric definitions be managed as code?

Managing metric definitions in tested, version-controlled repositories makes analytical logic reviewable and auditable. Teams can evaluate changes before deployment instead of silently modifying calculations inside individual dashboards.

A code-based workflow provides several practical controls:

  • Version history records when a definition changed and what changed.
  • Peer review allows data and business owners to inspect proposed logic.
  • Testing can detect broken references or unexpected behavior before release.
  • Coordinated deployment reduces the chance that consumers receive partially updated definitions.

This process also clarifies responsibility. Data teams can maintain technical correctness, while business stakeholders validate whether definitions reflect organizational meaning. When a metric changes, the shared layer gives teams one controlled place to update it rather than searching through every report and application.

Centralization should not mean that every calculation belongs in one undifferentiated catalog. Teams still need naming conventions, documented ownership, clear entity relationships, and policies for proposing or retiring metrics.

How can AI agents use a semantic layer safely?

A semantic layer gives AI agents and natural-language interfaces a trusted vocabulary for requesting business metrics. Instead of asking a model to invent SQL or infer calculation rules from raw schemas, an application can direct requests through approved semantic definitions.

For example, an agent answering a question about monthly revenue can request the governed metric with the required dimensions and period. MetricFlow then generates SQL according to established logic, reducing the risk that the agent chooses an incorrect table, join, or aggregation.

The semantic layer solves only part of the governance problem. Production systems must still authenticate the requesting user or workload, authorize access to the underlying data, apply row or column restrictions where required, and log activity. The agent should receive only metrics and dimensions allowed for its identity and task.

This makes the semantic layer a useful interface between governed data and automated decision systems. It complements the broader practice of creating data products for AI agents with defined meaning, ownership, quality expectations, and access controls.

Key takeaways

  • The dbt Semantic Layer centralizes metrics so dashboards, applications, and agents can use shared analytical logic.
  • MetricFlow translates metric requests into SQL using defined entities, measures, dimensions, relationships, and time rules.
  • Version-controlled definitions make business logic easier to test, review, audit, and deploy safely.
  • Semantic consistency reduces metric drift but does not replace data quality, identity, authorization, or monitoring controls.
  • Agents benefit from requesting approved business concepts rather than generating calculations directly from raw schemas.

How Hyperlake helps

Hyperlake can provide the governed data foundation around a reviewed semantic layer, including fitting analytical engines, identity-aware access, policy enforcement, observability, and lifecycle controls in infrastructure the organization or its client controls. Its modular approach lets teams package data services, models, applications, policies, and monitoring into repeatable deployments while keeping operational procedures dependent on the selected engines and solution. To discuss an architecture for governed metrics and AI applications, talk to our team.

Frequently asked questions

Does a semantic layer replace dashboards or business intelligence tools?

No. A semantic layer supplies consistent business definitions and query logic to dashboards, reporting workflows, and other applications. Business intelligence tools still provide visualization, exploration, and user-facing analysis, but they can request centrally governed metrics instead of maintaining separate calculations in every workbook or report.

Can MetricFlow prevent every disagreement about a business metric?

MetricFlow can ensure that consumers use the same implemented definition, but technology cannot resolve an unclear business decision by itself. Stakeholders must still agree on concepts such as recognized revenue, active customers, or reporting periods. Once approved, the semantic layer makes that agreement explicit, executable, versioned, and reusable.

What must be governed beyond the metric definition itself?

Teams must govern the source data, model relationships, access permissions, deployment process, and changes to business meaning. They should also authenticate people and workloads, enforce applicable data restrictions, and retain logs or lineage for review. A correct metric formula is insufficient if an unauthorized agent can query sensitive dimensions.

Is a semantic layer useful for natural-language analytics?

Yes, because it gives natural-language applications a controlled vocabulary mapped to established analytical logic. The language model can identify the requested metric and dimensions, while the semantic query engine generates SQL from governed definitions. Accuracy still depends on reliable intent interpretation, source data quality, access controls, and appropriate validation of the returned result.

Start with a workload. Build the environment around it.

Explore example deployments, or see how the platform assembles, deploys, governs and operates the stack.