Learn  /  Guides

The semantic layer is back: why AI agents need business context, and how to build it

Ask an AI "what was revenue last month?" and you may get three different answers. A semantic layer gives it one. What it is, the options in 2026, and how to start.

Guide10 min readUpdated 28 October 2026
Analytics engineeringData modellingAI
All guides and cheat sheets

Give a powerful AI model access to your data warehouse and ask a simple business question. Very often the answer is confidently wrong: it picks the wrong table, forgets to exclude refunds, or uses calendar months when finance uses fiscal ones. The model is not the problem. It simply does not know your business definitions. In 2026 the fix has a familiar name, the semantic layer, and every major data platform is racing to offer one.

Why AI gets business questions wrong

Take "What was revenue last month?" An AI working straight from tables has to make several decisions that are not in the data itself:

Which table?
orders, invoices or payments? Each gives a different number.
Which amounts?
Gross or net of VAT? Including refunds, discounts and cancelled orders?
Which month?
Calendar month, fiscal month, or the last 30 days?
Which currency?
Converted at today's rate or the rate on the day of the sale?

A semantic layer answers those questions once, in code, and every tool that asks for "revenue" gets the agreed answer.

What business context does to AI accuracy

Model with raw tables onlyModel with business context

Structured business questions24% 86%+62%

Snowflake's figures from Summit 2026 for structured business questions. Results vary by data and question; the direction is consistent across vendors.

What a semantic layer contains

From raw tables to a trustworthy answer
Raw tablesorders, refunds, fx_rates
Clean modelsbuilt and tested in dbt
Semantic layermetrics, dimensions, joins
Any consumerdashboard, SQL, AI agent
Metric
A named, agreed calculation: net_revenue = SUM(amount) - SUM(refunds), with filters such as "exclude test orders".
Dimension
The ways you slice a metric: region, product, customer segment, fiscal month.
Relationships
How tables join, so the agent never has to guess the join keys.
Descriptions
Plain-English explanations of each metric and column. AI models read these.
Time logic
Fiscal calendars, rolling windows, period-over-period comparisons.

A worked example

Here is the same metric defined in two popular formats. The idea is identical: a measure, how to aggregate it, and the dimensions it can be grouped by.

YAML
semantic_models:
  - name: orders
    model: ref('fct_orders')
    defaults:
      agg_time_dimension: order_date
    entities:
      - name: order_id
        type: primary
      - name: customer_id
        type: foreign
    dimensions:
      - name: order_date
        type: time
        type_params:
          time_granularity: day
      - name: region
        type: categorical
    measures:
      - name: net_revenue
        description: "Order value excluding VAT, minus refunds. Test orders excluded."
        agg: sum
        expr: amount_ex_vat - refund_amount

metrics:
  - name: net_revenue
    label: Net revenue
    type: simple
    type_params:
      measure: net_revenue

Once defined, an agent or a dashboard asks for net_revenue by region and the layer writes the correct SQL. Nobody, human or machine, has to remember to subtract refunds.

The options in 2026

dbt semantic layer

Platform-neutral
Lives in
your dbt project
Engine
MetricFlow, open source
  • Works across warehouses
  • Version-controlled with your models
  • Needs a dbt setup to serve queries

Best if you already use dbt and want portability.

Databricks metric views

In the lakehouse
Lives in
Unity Catalog
Used by
Genie, dashboards, SQL
  • Window measures for rolling metrics
  • Governed with your data
  • Databricks only

Best if Databricks is your main platform.

Snowflake semantic views

In the warehouse
Lives in
Horizon Catalog
Used by
CoWork, CoCo, Cortex Sense
  • Autopilot can draft and refine definitions
  • Feeds Snowflake's agents directly
  • Snowflake only

Best if Snowflake is your main platform.

How to start

  1. 1

    Pick ten metrics that matter

    Revenue, orders, active customers, churn: the numbers leadership asks about every week. Agree each definition in writing with its owner.

  2. 2

    Clean the models underneath

    A semantic layer on messy tables just spreads the mess. Build tested fact and dimension tables first.

  3. 3

    Write descriptions for humans and machines

    One or two sentences per metric and column. AI models use them to choose correctly.

  4. 4

    Define the layer in code

    Use dbt, metric views or semantic views, and keep it in version control with reviews.

  5. 5

    Test with real questions

    Ask your AI assistant 20 questions with known answers, before and after. Track the accuracy over time.

  6. 6

    Expand gradually

    Add metrics as people ask for them, not all at once.

Check your understanding

1/3Why do AI models often get business metrics wrong when given raw tables?

2/3What does a semantic layer store?

3/3What is the Open Semantic Interchange for?

The foundations matter: start with Star schema data modelling and your first dbt project, then see how the platforms compare in Snowflake vs Databricks for AI agents.

Sources: dbt semantic layer and MetricFlow documentation; Databricks metric views documentation; Snowflake Summit 2026 announcements (semantic views, Cortex Sense, OSI). Accuracy figures are vendor results; measure them on your own data.

Alessandro Ecclesie AgazziWritten by Alessandro Ecclesie Agazzi, analytics engineer in London. Updated 28 October 2026. About me

Found this useful?

New guides and "what's new" explainers on data and AI land here regularly. Follow along on LinkedIn, or share this one with a colleague.