What Is a Context Layer? Context vs Semantic Layer for AI

November 15, 2026 · By the SaturnSQL team

Ask an AI tool for last month’s revenue and it will happily write the SQL. Whether the number is right depends on things the schema never says: amounts are stored in cents, orders is the old table, and an “active customer” bought something in the last 90 days. A context layer is where that knowledge lives, so every AI tool reads it before it writes a query.

What is a context layer?

A context layer is what an AI tool reads about your data besides the schema. It holds the meaning a person would explain to a new analyst on their first day:

  • Notes for AI: rules that apply everywhere, such as “amounts are in cents” or “use orders_v2, not orders”.
  • Business definitions: what “active customer” or “churn” means, ideally with the SQL that computes it.
  • Descriptions and synonyms: what each table and column holds, and the words people use for it (“revenue” for total).
  • The database’s own comments, where someone already wrote them.

AI tools such as Claude, ChatGPT and Cursor read it through MCP before they write SQL, so they pick the right table and the right filter instead of guessing from column names. Most wrong AI queries are not bad SQL. They are correct SQL on a wrong assumption.

The term is not ours. Cube, Atlan, Snowflake and DataHub all talk about context layers, and the scope varies: some include lineage, ownership and access policies, others stay close to the meaning of tables and metrics.

What is a semantic layer?

A semantic layer defines metrics, dimensions and joins in code, in tools such as the dbt Semantic Layer, Cube or LookML. A dashboard or an AI asks for “revenue by month”, and the layer compiles the SQL. The point is consistency: revenue is the same number in every tool, because every tool asks the same layer.

The price is modelling up front. Someone, usually an analytics engineer, has to write and deploy the models before the first question gets an answer, and every new question that falls outside the model needs another change.

Context layer vs semantic layer

Context layerSemantic layer
What you build firstNothing. Write context files as questions come upModels, metrics and joins in YAML, LookML or views
How AI uses itReads the meaning, then writes SQLQueries governed metrics through an API
Who maintains itAnyone who knows the data, in plain languageUsually analytics engineers, in code
Same number every timeGuided by definitions, not guaranteedYes, metrics compile to the same SQL
Time to first answerMinutesOnce the first models are written and deployed

It is not either-or. Many teams start with context, because it helps from the first note, and model a semantic layer later for the few metrics that must never drift. Some vendors go further and treat the semantic layer as one part of the context layer. For the modelling side, see the best semantic layer tools.

Why your context layer should be portable

What your team writes into a context layer is knowledge: years of “don’t use that table” and “that column is in cents”. Keep it in one vendor’s closed format and it is stuck there.

  • You will use more than one AI tool. Claude today, Cursor for the engineers, something else next year. They should all read the same meaning.
  • The field moves faster than any vendor. New AI tools, new models and new standards arrive every few months, and nobody knows which ones will matter in two years. The meaning of your data changes slowly. Keep the slow part in an open format, and you can swap the fast parts without starting over.
  • Your stack will change. Warehouses, BI tools and catalogs get replaced. Rewriting every definition each time is how they rot.
  • Meaning deserves review. A definition of revenue is as important as the code that computes it. In an open text format it can live in git, with diffs and pull requests.
  • Leaving should be cheap. The more of your knowledge sits in a tool you can’t export from, the harder that tool is to replace.

The fix is the one that worked for code: keep it in an open format that any tool can read and write.

Apache Ossie: an open format for semantic models

Apache Ossie is an open, vendor-neutral format for semantic models. Snowflake started it in 2025 with 17 launch partners, and contributors have since come from Dremio, Salesforce, Databricks, dbt Labs, RelationalAI, GoodData, Honeydew and more, over 50 organizations in all. On July 10, 2026 it entered the Apache Incubator under the Apache-2.0 licence. The announcement has the details.

An Ossie model is a YAML file: a version, a name, datasets (tables and their fields), relationships and metrics. It also has room for what AI tools need, instructions and synonyms under ai_context. Here is a small one, as SaturnSQL Context exports it:

version: 0.3.0.dev0
name: shop
ai_context:
  instructions: Amounts are in cents. Use orders_v2, not orders.
datasets:
  - name: orders_v2
    source: shop.public.orders_v2
    primary_key:
      - id
    description: One row per paid order
    fields:
      - name: total
        expression:
          sql: total
        datatype: Integer
        description: Order total in cents, before VAT
        ai_context:
          synonyms:
            - revenue
            - amount
metrics:
  - name: revenue
    expression:
      dialects:
        - dialect: POSTGRESQL
          expression: SUM(total) / 100.0
    description: Paid order totals in euros, before VAT

The project also maintains converters between Ossie and other formats, among them dbt, Snowflake, Databricks, BigQuery, Cube and Apache Polaris.

How do you deploy Apache Ossie?

You don’t, at least not in the server sense. Ossie is a specification, not a service: there is nothing to host and no Terraform module to apply. A semantic model is a file, and the usual workflow looks like code:

  1. Keep the .ossie.yaml files in git, next to your dbt project or in a repo of their own.
  2. Change them through pull requests, so a new definition of revenue gets reviewed like any other change.
  3. Check them in CI with the validation script in the Ossie repository.
  4. Bring them into each tool with a converter, or import them directly into tools that read Ossie.

Terraform still has a job: it deploys the warehouse and the tools that consume the model. The model itself just travels between them as YAML. Work is also under way to make semantic models discoverable from the Apache Polaris catalog, which would give teams a shared place to publish them.

How SaturnSQL Context uses Ossie

SaturnSQL Context is a context layer for AI on the databases you already have: context files, definitions, descriptions and synonyms, read by Claude, ChatGPT, Cursor, Claude Code, Windsurf or any other MCP client through SaturnSQL’s MCP server, so every AI tool your team uses gets the same answers. It keeps that knowledge portable:

  • Export on every plan: each connection as Apache Ossie YAML or a dbt schema.yml. Definitions with SQL become Ossie metrics, and context files go under ai_context.
  • Import on the Pro plan: start from the Ossie model you already have, with a preview of what will change before anything is saved.
  • From an AI tool: the MCP tools export_ossie and import_ossie do the same from a conversation.

The details are in Apache Ossie import and export.

Frequently asked questions

Is a context layer the same as a semantic layer?

No. A semantic layer defines metrics, dimensions and joins in code and compiles them to SQL, so a number comes out the same in every tool. A context layer describes what the data means in plain language, so an AI tool can write the SQL itself. Some vendors treat the semantic layer as one part of a wider context layer.

How do you deploy Apache Ossie?

You don’t run it anywhere. Ossie is a specification, not a service, so there is no server and no Terraform module. A semantic model is a YAML file: teams keep it in git, review changes in pull requests, and use converters or tools that read Ossie to bring it into dbt, a warehouse, a BI tool or a context layer.

Do I need a semantic layer before a context layer?

No. A context layer works from the first note you write. Many teams start with context and model a semantic layer later for the few metrics, such as revenue, that must match to the cent in every tool.

Give AI the meaning of your data, and keep it yours