Skip to main content

Sidemantic

Sidemantic is an open-source semantic runtime. Define governed metrics once—or import the semantic models you already have—and query them consistently from SQL, the CLI, Python, HTTP, PostgreSQL clients, notebooks, BI tools, and AI agents.

  • Bring existing models: Power BI TMDL/DAX, Cube, dbt MetricFlow, LookML, Hex, Rill, Superset, Omni, BSL, GoodData LDM, Snowflake Cortex, Malloy, Apache Ossie, AtScale SML, and ThoughtSpot TML
  • Or author natively: concise YAML, semantic SQL DDL, or Python
  • Run on your warehouse: DuckDB, MotherDuck, PostgreSQL, BigQuery, Snowflake, ClickHouse, Databricks, Spark SQL, and ADBC sources
  • Consume metrics anywhere: semantic SQL, CLI, Python, HTTP/Arrow, PostgreSQL wire protocol, MCP, notebooks, TypeScript/WASM, and embedded analytics

Documentation | GitHub | Docker Hub | Discord | Demo (50+ MB data download, runs in your browser with Pyodide + DuckDB)

Jupyter Widget Preview

Sidemantic ships Claude Code and Codex plugin metadata for two skills (modeler and webapp-builder). See Agent Plugin below to install.

Contributors working on browser surfaces should read the UI architecture and canonical ownership map.

60-second quickstart

See it working before writing anything — one command creates a complete demo project (models, sample DuckDB data, golden tests) and runs a first query:

uvx sidemantic demo

Start from your own data — Sidemantic introspects it and generates models with inferred dimensions, metrics, and relationships:

uvx sidemantic init analytics --from data/*.csv     # also Parquet, JSON, DuckDB
cd analytics
sidemantic query "SELECT orders.record_count FROM orders"
sidemantic test              # golden-query assertions
sidemantic validate --live   # models vs. actual database schema
sidemantic serve             # web UI + HTTP API + MCP on one port

Or write a model by hand. Create models/orders.yml:

models:
  - name: orders
    sql: |
      select * from (values
        (1, 'paid',    120.00),
        (2, 'paid',     80.00),
        (3, 'pending',  50.00)
      ) as t(id, status, amount)
    primary_key: id
    dimensions:
      - name: status
        type: categorical
        sql: status
    metrics:
      - name: revenue
        agg: sum
        sql: amount
      - name: order_count
        agg: count

Query it directly—no database setup or package installation required:

uvx sidemantic query \
  "SELECT orders.status, orders.revenue, orders.order_count
   FROM orders
   ORDER BY orders.status" \
  --models ./models
status,revenue,order_count
paid,200.00,2
pending,50.00,1

From here, inspect generated warehouse SQL or open an interactive explorer:

# Compile without executing
uvx sidemantic query \
  "SELECT orders.status, orders.revenue FROM orders" \
  --models ./models --dry-run

# Explore in the terminal
uvx --from "sidemantic[workbench]" sidemantic workbench ./models

Choose your path

  • Import existing semantic models: point Sidemantic at a Cube, MetricFlow, LookML, Power BI, Malloy, Rill, or other supported project. Start with the adapter guide.
  • Model tables or SQL: continue with models, dimensions, metrics, and relationships.
  • Query governed metrics: use the CLI, semantic SQL, or Python API.
  • Explore data: launch the terminal workbench, notebook widget, or browser UI.
  • Serve other tools: expose models over the HTTP API, PostgreSQL wire protocol, or MCP server.

Install Sidemantic in a project with uv add sidemantic. Optional features are packaged as extras: malloy, dax, workbench, widget, api, and serve.

DAX And TMDL

DAX/TMDL support lives behind the dax extra because it includes a native Rust parser:

uv add "sidemantic[dax]"

Native Sidemantic YAML can preserve DAX expression source text for Power BI interoperability:

models:
  - name: sales
    table: sales
    primary_key: id
    dimensions:
      - name: doubled_amount
        type: numeric
        dax: "'sales'[amount] * 2"
    metrics:
      - name: revenue
        dax: "SUM('sales'[amount])"

Power BI TMDL projects can be loaded from a project root or definition/ folder. Embedded DAX measures, calculated columns, calculated tables, relationships, and TMDL passthrough metadata are parsed and preserved in model metadata:

from sidemantic import SemanticLayer, load_from_directory

layer = SemanticLayer(connection="duckdb:///warehouse.duckdb")
load_from_directory(layer, "powerbi_project/")
print(layer.describe_models(["Sales"]))

TMDL can also round-trip back to disk:

from sidemantic.adapters.tmdl import TMDLAdapter

TMDLAdapter().export(layer.graph, "exported_tmdl/")

CLI

# Scaffold a project (optionally generating models from your data)
sidemantic init
sidemantic init --from data/orders.csv --from data/customers.parquet

# Self-contained demo project with sample data
sidemantic demo

# Query as a human-readable table (also supports csv, json, and jsonl)
sidemantic query "SELECT revenue FROM orders" --db data.duckdb --format table

# Query raw files directly (CSV, Parquet, JSON become tables named by file stem)
sidemantic query "SELECT orders.revenue FROM orders" --db data/orders.csv

# Golden-query tests: pin expected metric values so definitions cannot drift
sidemantic test

# Serve teammates and tools on one port: web UI, HTTP API, and MCP
uvx --from "sidemantic[api,mcp]" sidemantic serve models/ --db data.duckdb

# Interactive workbench (TUI with SQL editor + charts)
uvx --from "sidemantic[workbench]" sidemantic workbench models/ --db data.duckdb

# PostgreSQL server (connect Tableau, DBeaver, etc.)
uvx --from "sidemantic[serve]" sidemantic server postgres models/ --port 5433

# HTTP API server (JSON or Arrow)
uvx --from "sidemantic[api]" sidemantic server api models/ --port 4400 --auth-token-file .secrets/api-token

# Validate definitions (--live also checks tables/columns against the database)
sidemantic validate models/
sidemantic validate models/ --live --db data.duckdb

# Model info
sidemantic info models/

# Pre-aggregation recommendations
sidemantic preagg recommend --db data.duckdb

# Migrate SQL queries to semantic layer
sidemantic migrate generate legacy/ --output output/

See the CLI contract for output formats, --plain, quiet/verbose diagnostics, option placement, terminal behavior, environment precedence, stdin/stdout, exit codes, debugging, and secure credential input.

Demos

Workbench (TUI with SQL editor + charts):

uvx --from "sidemantic[workbench]" sidemantic workbench --demo

PostgreSQL server (connect Tableau, DBeaver, etc.):

uvx --from "sidemantic[serve]" sidemantic server postgres --demo --port 5433

HTTP API server (JSON or Arrow):

uvx --from "sidemantic[api]" sidemantic server api --demo --port 4400

Colab notebooks:

Open in Colab SQL + DuckDB

Open in Colab LookML multi-entity

SQL syntax:

uv run https://raw.githubusercontent.com/sidequery/sidemantic/main/examples/sql/sql_syntax_example.py

Comprehensive demo:

uv run https://raw.githubusercontent.com/sidequery/sidemantic/main/examples/advanced/comprehensive_demo.py

Symmetric aggregates:

uv run https://raw.githubusercontent.com/sidequery/sidemantic/main/examples/features/symmetric_aggregates_example.py

Superset with DuckDB:

git clone https://github.com/sidequery/sidemantic.git && cd sidemantic
uv run examples/superset_demo/run_demo.py

Cube Playground:

git clone https://github.com/sidequery/sidemantic.git && cd sidemantic
uv run examples/cube_demo/run_demo.py

Rill Developer:

git clone https://github.com/sidequery/sidemantic.git && cd sidemantic
uv run examples/rill_demo/run_demo.py

Apache Ossie (complex adtech semantic model):

git clone https://github.com/sidequery/sidemantic.git && cd sidemantic
uv run examples/osi_demo/run_demo.py

Apache Ossie widget notebook (percent-cell Python notebook):

git clone https://github.com/sidequery/sidemantic.git && cd sidemantic
uv run examples/osi_demo/osi_widget_notebook.py

See examples/ for more.

Core Features

  • SQL query interface with automatic rewriting
  • Automatic joins across models
  • Multi-format adapters (Cube, MetricFlow, LookML, Hex, Rill, Superset, Omni, BSL, GoodData LDM, Apache Ossie, AtScale SML, ThoughtSpot TML, Graphene GSQL)
  • SQLGlot-based SQL generation and transpilation
  • Pydantic validation and type safety
  • Pre-aggregations with explicit routing
  • Predicate pushdown for faster queries
  • Segments and metric-level filters
  • Jinja2 templating for dynamic SQL
  • PostgreSQL wire protocol server for BI tools
  • HTTP API with JSON and Arrow IPC responses

Multi-Format Support

Auto-detects: Sidemantic (SQL/YAML), Power BI TMDL, Cube, MetricFlow (dbt), LookML, Hex, Rill, Superset, Omni, BSL, GoodData LDM, Apache Ossie, AtScale SML, ThoughtSpot TML, Graphene GSQL

sidemantic query "SELECT revenue FROM orders" --models ./my_models
from sidemantic import SemanticLayer, load_from_directory

layer = SemanticLayer(connection="duckdb:///data.duckdb")
load_from_directory(layer, "my_models/")  # Auto-detects formats

Apache Ossie is registered as format ossie; osi, apache-ossie, and open-semantic-interchange remain accepted aliases. Use an explicit format when selecting an Ossie scope or execution dialect:

sidemantic convert commerce.ossie.yaml \
  --from ossie --to sidemantic --output models.yml \
  --ossie-scope commerce --ossie-target-dialect bigquery

sidemantic convert models/orders.yml \
  --from sidemantic --to ossie --output commerce.ossie.yaml \
  --ossie-scope commerce --ossie-expression-dialect BIGQUERY

See the Apache Ossie compatibility guide for the pinned schema profiles, validation policies, scope rules, and round-trip limits.

Databases

Database Status Installation
DuckDB ✅ built-in
MotherDuck ✅ built-in
PostgreSQL ✅ uv add sidemantic[postgres]
BigQuery ✅ uv add sidemantic[bigquery]
Snowflake ✅ uv add sidemantic[snowflake]
ClickHouse ✅ uv add sidemantic[clickhouse]
Databricks ✅ uv add sidemantic[databricks]
Spark SQL ✅ uv add sidemantic[spark]

Docker

The published image is sidequery/sidemantic on Docker Hub. Mount your models directory as a volume at /app/models:

docker run -p 5433:5433 -v ./models:/app/models sidequery/sidemantic

Demo mode (built-in sample data, no volume needed):

docker run -p 5433:5433 sidequery/sidemantic --demo

See examples/docker/ for MCP mode, env vars, building from source, and integration test services.

For Cloudflare Worker + Container deployment, see examples/cloudflare_containers/.

HTTP API

Start the API server:

uvx --from "sidemantic[api]" sidemantic server api models/ --db data.duckdb --port 4400 --auth-token-file .secrets/api-token

Compile a structured semantic query:

curl -s http://localhost:4400/compile \
  -H "Authorization: Bearer secret" \
  -H "Content-Type: application/json" \
  -d '{"dimensions":["orders.status"],"metrics":["orders.total_amount"]}'

Run a structured query as JSON:

curl -s http://localhost:4400/query \
  -H "Authorization: Bearer secret" \
  -H "Content-Type: application/json" \
  -d '{"dimensions":["orders.status"],"metrics":["orders.total_amount","orders.order_count"]}'

Run a structured query as Arrow IPC:

curl -s http://localhost:4400/query \
  -H "Authorization: Bearer secret" \
  -H "Accept: application/vnd.apache.arrow.stream" \
  -H "Content-Type: application/json" \
  -d '{"metrics":["orders.order_count"]}' \
  > result.arrow

Execute rewritten SQL over HTTP:

curl -s http://localhost:4400/sql \
  -H "Authorization: Bearer secret" \
  -H "Content-Type: application/json" \
  -d '{"query":"SELECT status, total_amount FROM orders ORDER BY status"}'

Agent Plugin

Sidemantic ships a plugin bundle with Claude Code and Codex metadata for two skills:

  • modeler — build, validate, and query semantic models
  • webapp-builder — generate analytics webapps from your models

Install in Claude Code:

claude plugin marketplace add sidequery/sidemantic && claude plugin install sidemantic@sidequery

Install in Codex:

codex plugin marketplace add sidequery/sidemantic && codex plugin add sidemantic@sidequery

Use a local clone while developing:

claude --plugin-dir ./plugins/sidemantic
codex plugin marketplace add . && codex plugin add sidemantic@sidequery

The Claude Code plugin manifest lives at plugins/sidemantic/.claude-plugin/plugin.json, and its marketplace lives at .claude-plugin/marketplace.json.

The Codex plugin manifest lives at plugins/sidemantic/.codex-plugin/plugin.json, and its repo-local marketplace lives at .agents/plugins/marketplace.json.

The skills also work with other SKILL.md-compatible agents by pointing them at plugins/sidemantic/skills/.

How mature is Sidemantic?

Sidemantic is an ambitious but young semantic layer project. You could encounter rough patches, especially with the more exotic features like converting between semantic model formats or serving semantic layers via the included Postgres protocol server.

Testing

uv run pytest -v

This prints line coverage for sidemantic with missing lines in the terminal.

Metadata

Release files for sidemantic 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sidemantic 0.12.0
File Size Uploaded
sidemantic-0.12.0.tar.gz 6.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for sidemantic 0.12.0
File Interpreter ABI Platform
sidemantic-0.12.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 MB

Release files / sidemantic-0.12.0.tar.gz

Download URL sidemantic-0.12.0.tar.gz
Size 6.3 MB
Tags Source
SHA-256 checksum
How to use checksums
4401ce6bc2271250c05202d14bc18f8899f44efa7b73b8b28d61c5e4834e6a1c
BLAKE2b-256 checksum
How to use checksums
34aada673af804987965d53236728b932e175e49c983f8d459348922703b56c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sidemantic-0.12.0-py3-none-any.whl

Download URL sidemantic-0.12.0-py3-none-any.whl
Size 3.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
dbd8597a6dd070147f3e64e65cffaecc0f47e2f83a41c5f19838e1f7ed7d5c70
BLAKE2b-256 checksum
How to use checksums
d60ea71b40b02dc9db6e2aaceab8bcafdd4e62c47ad5fbc9c695c0338227ec25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.12.0 This release

2 release files

0.11.0

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.11

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.9

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page