/

Semantic Layer

Build an Enterprise Semantic Layer: Architecture & Checklist

Intergalactic Data Labs

—

—

14 min read

Table of contents

Summarize

Updated October 2026

To build an enterprise semantic layer, shape clean tables first, then declare entities, dimensions, and metrics as code. Test every metric against a trusted number, validate changes in CI, and serve the same definitions to BI tools and AI agents. Start with one domain and expand only after the numbers match.

Build stage

What you produce

Test that gates the next stage

1. Scope

One domain, 5 to 10 metrics, owners

Reference numbers signed off

2. Shape tables

Facts and dimensions at known grain

Unique and not-null keys pass

3. Model

Entities, dimensions, metrics in code

No blocked or fan-out joins

4. Test

Unit, data, and reconciliation tests

Metrics match reference values

5. CI

Validation on every pull request

Generated SQL runs in the warehouse

6. Serve

BI connections and agent tools

Every consumer reads the layer

This guide covers the engineering work. For the definition, the four architecture patterns, and a planning checklist, read what is a semantic layer. For a vendor ranking, see top semantic layer tools for 2026.

What do you need before you build a semantic layer?

You need a scoped domain, a list of metrics with owners, and a trusted reference number for each metric. Without reference numbers you cannot tell whether the new layer is right. Choose metrics that already cause arguments, such as net revenue or active customers.

You also need tables that are modeled well enough to describe. That usually means a transformation layer that produces facts and dimensions at a known grain. Finally, list your consumers up front, including dashboards, spreadsheets, apps, and agents. The consumer list decides which engine and which interfaces you need.

Which engine should hold your semantic definitions?

Pick the engine that matches where your data lives and who must read it. A warehouse-native option is fastest when one platform holds most data. A universal layer fits when many tools and platforms need the same metrics. The table compares four common choices.

Engine

Where definitions live

Main strength

Documented limit

dbt Semantic Layer

YAML on dbt models

Native CI validation

Hosted APIs depend on plan

Cube

YAML or JavaScript in Git

Many APIs plus caching

Another service to run

Snowflake semantic views

Schema objects in Snowflake

Read by Cortex agents

Covers Snowflake data

Databricks metric views

Unity Catalog objects

Built-in materialization

Covers Databricks data

The dbt Semantic Layer runs on MetricFlow, which is open source under Apache 2.0 (dbt Labs). Its hosted APIs and the tools available through them vary by plan (dbt docs). dbt Labs and Fivetran completed their merger in June 2026, so check roadmap news before you commit (Fivetran).

Cube keeps models in version control and serves them through SQL, REST, GraphQL, and a Meta API for discovery (Cube docs). Snowflake semantic views can be created in SQL, in Semantic Studio, or with Semantic View Autopilot from YAML, Tableau, or Power BI files (Snowflake docs). Databricks metric views live in Unity Catalog and can pre-compute aggregations (Databricks docs).

How should you shape tables before modeling?

Give every table one grain and one primary key before you describe it. Grain is what a single row represents, such as one order or one customer per day. If you cannot state the grain in one sentence, fix the table before you model it.

A star layout is the easiest shape to describe. Fact tables hold events and amounts, and dimension tables hold attributes such as region or plan. Keep dimensions conformed, so the customer table that sales uses is the same one finance uses.

Build a time spine early

Most engines need a calendar table for time-based metrics. MetricFlow requires a time spine at daily grain at minimum. It uses the spine for cumulative metrics, metric offsets, conversion metrics, and Type II slowly changing dimensions (dbt docs). Add fiscal periods as custom grains if finance reports on a non-standard calendar.

Resolve identities upstream

Metrics that join systems need one key per real-world entity. If the CRM and billing system disagree about who a customer is, no metric definition will fix it. Do that matching in the transformation layer. Our guide to identity resolution for the context layer covers the methods.

Which modeling patterns hold up in production?

The patterns that last declare join keys explicitly, keep metric logic in one place, and name things the way the business speaks. Each pattern below prevents a common class of wrong number.

Declare entities so the engine can block bad joins

Entities are the join keys of a semantic model. dbt defines primary, unique, foreign, and natural entity types (dbt docs). MetricFlow uses those types to choose left joins and to block joins that would fan out rows. It also limits multi-hop joins to two hops (dbt docs).

That rule is a feature. When the engine refuses a join, it usually means a key or grain is wrong upstream. Fix the table rather than forcing the join.

Build complex metrics from simple ones

Define base aggregations once, then compose ratios and derived metrics from them. In dbt v1.12 and later, simple metrics replace the older measures, and metrics sit next to the model they describe (dbt docs). A sketch of the newer layout follows. Check the syntax against your dbt version.

models:
  - name: fct_invoices
    semantic_model:
      enabled: true
    agg_time_dimension: invoice_date
    columns:
      - name: invoice_id
        entity: {type: primary, name: invoice}
      - name: account_id
        entity: {type: foreign, name: account}
      - name: invoice_date
        granularity: day
        dimension: {type: time}
    metrics:
      - name: net_revenue
        type: simple
        agg: sum
        expr: case when status = 'paid' and not is_refund then amount else 0 end
models:
  - name: fct_invoices
    semantic_model:
      enabled: true
    agg_time_dimension: invoice_date
    columns:
      - name: invoice_id
        entity: {type: primary, name: invoice}
      - name: account_id
        entity: {type: foreign, name: account}
      - name: invoice_date
        granularity: day
        dimension: {type: time}
    metrics:
      - name: net_revenue
        type: simple
        agg: sum
        expr: case when status = 'paid' and not is_refund then amount else 0 end
models:
  - name: fct_invoices
    semantic_model:
      enabled: true
    agg_time_dimension: invoice_date
    columns:
      - name: invoice_id
        entity: {type: primary, name: invoice}
      - name: account_id
        entity: {type: foreign, name: account}
      - name: invoice_date
        granularity: day
        dimension: {type: time}
    metrics:
      - name: net_revenue
        type: simple
        agg: sum
        expr: case when status = 'paid' and not is_refund then amount else 0 end
Treat balances differently from flows

Some values cannot be summed across time. Account balances, inventory levels, and seat counts are snapshots, so the right answer is usually the last value in a period. Model these with an explicit rule for which row to use, and test them with a known period end.

Name things the way people ask

Use business names, descriptions, and synonyms that match how people phrase questions. Databricks metric views carry agent metadata such as synonyms and display names to improve agent accuracy (Databricks docs). Good names help analysts and models pick the right metric on the first try.

How do you test a semantic layer?

Test at three levels, which are logic, data, and numbers. Logic tests catch broken transformations. Data tests catch broken keys. Reconciliation tests catch metrics that run fine but return the wrong value.

Test type

What it catches

When it runs

Unit test

Wrong SQL logic on fixed inputs

Development and CI

Data test

Duplicate keys, nulls, bad values

After each build

Semantic validation

Queries that will not execute

Every pull request

Reconciliation

Metric differs from reference

CI and scheduled

Policy test

Wrong rows or columns per role

Before each release

dbt added unit tests in v1.8. They check a model against hand-written input rows and are meant for development and CI rather than production (dbt docs). Use them on models with tricky date math, many case branches, or past bugs.

Reconciliation is the test business users care about. Store each certified metric's reference value, query the layer for the same period, and fail when the gap exceeds a tolerance you agreed with the owner. dbt saved queries are a handy way to keep these golden queries as named, versioned nodes (dbt docs).

How do you put semantic changes through CI?

Run every definition change through a pull request that builds the changed models and validates the semantic nodes that depend on them. dbt documents this two-step pattern for CI jobs (dbt docs).

dbt build --select state:modified+
dbt sl validate --select state:modified

dbt build --select state:modified+
dbt sl validate --select state:modified

dbt build --select state:modified+
dbt sl validate --select state:modified

The validation step runs explain queries in the warehouse to prove the generated SQL will execute. Unchanged nodes defer to production, which keeps runs fast. Add your reconciliation queries as a third step so a pull request that moves a certified number fails review.

Require an approving review from the metric owner for any change to a certified definition. Version breaking changes and announce retirements ahead of time, the way you would for an API. Cube follows the same idea, since its models live in Git and can be edited through normal Git workflows (Cube docs).

How do you serve the semantic layer to BI tools?

Connect each BI tool through the interface your engine supports natively, and use exports for tools that have no connector. The goal is that no dashboard keeps its own copy of metric logic.

The dbt Semantic Layer lists native integrations for Power BI, Tableau, Excel, Google Sheets, Hex, Mode, and others. It also offers JDBC, GraphQL, and a Python SDK for custom clients (dbt docs). Exports write a saved query to a table or view, which helps tools without a native integration (dbt docs).

Cube speaks a Postgres-compatible SQL API, so most SQL clients can connect (Cube docs). Snowflake semantic views are queried with a SEMANTIC_VIEW clause that names metrics and dimensions (Snowflake docs). Databricks metric views are available to Power BI, Tableau, and Sigma as well as Databricks dashboards (Databricks docs).

Plan for performance

Semantic layers generate SQL at query time, so popular dashboards can get expensive. Cube pre-aggregations store rollups in Cube Store and refresh hourly by default (Cube docs). Databricks metric views can materialize aggregations and rewrite queries to use them (Databricks docs). Cache the metrics people open every morning and leave the rest live.

How do you serve the semantic layer to AI agents?

Expose the layer through MCP tools that let an agent discover metrics, inspect dimensions, and then query by name. That keeps the agent inside governed definitions instead of writing SQL against raw tables.

The dbt MCP server includes tools such as list_metrics, get_dimensions, get_metrics_compiled_sql, and query_metrics (dbt docs). Snowflake's managed MCP server can expose Cortex Analyst over a semantic view as a tool (Snowflake docs). Cube's Meta API lets agents see what is queryable before they ask (Cube docs).

The evidence for this design is growing. An April 2026 study found explicit business semantics raised accuracy 17 to 23 points across Claude Opus 4.7, Claude Sonnet 4.6, and GPT-5.4 (arXiv). dbt reported 98 to 100 percent accuracy through its semantic layer against 84 to 90 percent for text-to-SQL. That vendor test covered only 11 questions (dbt).

Log the compiled SQL for every agent request so humans can audit answers. Prefer tools that fail with a clear error when a metric does not exist. For when to pair the layer with retrieval or a graph, see RAG vs knowledge graph vs semantic layer.

How do you enforce access control across every consumer?

Define row and column rules once, at the point every consumer passes through, and test them with real roles. Agents should get exactly the access of the person or service they act for.

Cube supports access policies on cubes and views with row-level filters, member-level rules for columns, and masking (Cube docs). In Snowflake, querying a semantic view needs SELECT on the view but not on its underlying tables (Snowflake docs). That makes grants on the semantic view a security decision in their own right.

Who should own the definitions you build?

Your company should own them. Metric and entity definitions encode how the business actually works, which makes them one of its most valuable assets. Keep them in your own repository, in open formats, on infrastructure you control.

Open formats make that practical. dbt semantic models can now be written as Apache Ossie documents (dbt docs). Ossie, formerly the Open Semantic Interchange, entered the Apache Incubator in July 2026 (Apache Ossie).

Teams that want help often bring in a build partner. Galaxy is an applied lab that builds semantic layers and ontologies on the stack a team already runs, using internal tooling it plans to open source. It already builds in the open with Filament, its Apache 2.0 data movement engine. For the strategy side, see the semantic layer playbook for data leaders.

What mistakes slow a semantic layer build down?

Most delays come from skipping the unglamorous steps. These are the ones that show up again and again.

  • Modeling before agreeing. YAML written before owners agree just moves the argument into review.

  • Unclear grain. Mixed grain causes blocked joins or double counts.

  • No reference numbers. Nobody can prove the layer is right.

  • Side doors. Dashboards that still query raw tables break consistency.

  • Untested policies. Rules never tested with real roles leak data.

Frequently asked questions

What is the first step in building an enterprise semantic layer?

Pick one domain and five to ten metrics that people already argue about, such as net revenue or active customers. Write down an owner and a trusted reference number for each one. Those reference numbers become your first tests. Only after that should you shape tables, choose join keys, and write metric definitions in your chosen engine.

Do I need a star schema before adding a semantic layer?

You need clean tables with one known grain and a stable primary key, and a star schema is the simplest way to get there. Fact tables hold events and amounts, and dimension tables hold descriptive attributes. Engines such as MetricFlow choose join types from the entity keys you declare, so messy grain leads to blocked or wrong joins.

How do you test a semantic layer?

Use three layers of tests. Unit tests check transformation logic against small hand-written inputs. Data tests check keys, nulls, and accepted values in built tables. Reconciliation tests compare each metric to a trusted reference number. In dbt, the sl validate command also runs explain queries in the warehouse to prove the generated SQL will execute.

How do you add a semantic layer to CI?

Treat definitions as code in a Git repository and validate them on every pull request. In dbt, a CI job can build modified models and then run dbt sl validate on modified semantic nodes and their dependents. Add reconciliation queries for certified metrics so a change that moves a number fails review before it reaches production.

How do BI tools connect to a semantic layer?

It depends on the engine. The dbt Semantic Layer offers native integrations for Tableau, Power BI, Excel, and Google Sheets, plus JDBC, GraphQL, and a Python SDK. Cube exposes a Postgres-compatible SQL API. Snowflake semantic views are queried with a SEMANTIC_VIEW clause in SQL, and Databricks metric views work with Power BI, Tableau, and Sigma.

How do AI agents use a semantic layer?

Most agents connect through the Model Context Protocol. The dbt MCP server exposes tools to list metrics, get dimensions, and query metrics. Snowflake can expose Cortex Analyst over a semantic view as an MCP tool. The agent discovers governed metrics first and then requests them by name, so it never has to guess joins in raw tables.

Does a semantic layer improve AI answer accuracy?

Published evidence says yes, with caveats. An April 2026 study found explicit business semantics added 17 to 23 points of accuracy across three frontier models. A dbt benchmark reported 98 to 100 percent accuracy through its semantic layer against 84 to 90 percent for text-to-SQL, but that test covered only 11 questions and was run by the vendor.

Where should access control live in a semantic layer?

Put row and column rules where every consumer passes through them. Cube lets you define access policies with row filters and member rules on cubes and views. In Snowflake, users can query a semantic view without SELECT on its underlying tables, so grants on the view itself matter. Test policies with real roles before you open access.

How long does it take to build a semantic layer?

Scope drives the timeline more than tooling does. One domain with a handful of tested metrics, clear owners, and one consuming tool is a realistic first release. Broad rollout takes far longer because the slow work is agreeing on definitions across teams. Ship one domain, prove the numbers match, and then add domains one at a time.

Should semantic definitions live in a vendor tool or in our own repository?

Keep them in your own repository whenever you can. Definitions describe how your business works, which makes them valuable institutional knowledge. Code in Git can be reviewed, versioned, and moved. Open formats such as Apache Ossie and the Apache 2.0 MetricFlow engine make it easier to switch tools later without rewriting every metric.

More articles

Stay up to date with what we’re building

Stay up to date with what we’re building

Stay up to date with what we’re building

Questions

Answered

FAQ

What does Galaxy do?

What is Filament?

What is enterprise context management?

What does working with Galaxy look like?

How do you handle security and compliance?

Why does Galaxy build in the open?

Own your knowledge stack

Own your knowledge stack

Copyright © 2026 Galaxy. All rights reserved.