Universal semantic layer - import from Cube, dbt, LookML, Hex, and more
Project description
Sidemantic
SQL-first semantic layer for consistent metrics across your data stack.
- Formats: Sidemantic, Cube, MetricFlow (dbt), LookML, Hex, Rill, Superset, Omni, BSL
- Databases: DuckDB, MotherDuck, PostgreSQL, BigQuery, Snowflake, ClickHouse, Databricks, Spark SQL
Documentation • GitHub • Discord
Quickstart
Install:
uv add sidemantic
Define your semantic layer (SQL shown; YAML and Python are also supported):
-- semantic_layer.sql
MODEL (name orders, table orders, primary_key order_id);
DIMENSION (name status, type categorical, sql status);
DIMENSION (name order_date, type time, sql created_at, granularity day);
METRIC (name revenue, agg sum, sql amount);
METRIC (name order_count, agg count);
Query with familiar SQL:
from sidemantic import SemanticLayer
layer = SemanticLayer.from_yaml("semantic_layer.sql", connection="duckdb:///data.duckdb")
result = layer.sql("""
select revenue, status
from orders
where status = 'completed'
""")
rows = result.fetchall()
Demos
Colab:
| Demo | Open in Colab |
|---|---|
| SQL model definitions + DuckDB | |
| LookML multi-entity + DuckDB + chart |
Local notebooks:
examples/sidemantic_sql_duckdb_demo.ipynbexamples/lookml_multi_entity_duckdb_demo.ipynb
Core Features
- SQL query interface with automatic rewriting
- Automatic joins across models
- Multi-format adapters (Cube, MetricFlow, LookML, Hex, Rill, Superset, Omni, BSL)
- SQLGlot-based SQL generation and transpilation
- Pydantic validation and type safety
- Pre-aggregations with automatic routing
- Predicate pushdown for faster queries
- Segments and metric-level filters
- Jinja2 templating for dynamic SQL
- PostgreSQL wire protocol server for BI tools
Formats and Databases
Formats
Import from: Sidemantic (native), Cube, MetricFlow (dbt), LookML (Looker), Hex, Rill, Superset (Apache), Omni, BSL (Boring Semantic Layer).
Adapter compatibility details: https://sidemantic.com
Databases
| Database | Status | Installation |
|---|---|---|
| DuckDB | ✅ | built-in |
| MotherDuck | ✅ | built-in |
| PostgreSQL | ✅ | pip install sidemantic[postgres] |
| BigQuery | ✅ | pip install sidemantic[bigquery] |
| Snowflake | ✅ | pip install sidemantic[snowflake] |
| ClickHouse | ✅ | pip install sidemantic[clickhouse] |
| Databricks | ✅ | pip install sidemantic[databricks] |
| Spark SQL | ✅ | pip install sidemantic[spark] |
CLI
# Interactive workbench
uvx sidemantic workbench --demo
# Run a query
sidemantic query semantic_models/ --sql "select orders.revenue from orders"
# PostgreSQL wire protocol server
sidemantic serve semantic_models/ --port 5433
# Validate definitions
sidemantic validate semantic_models/
Load From Multiple Formats
from sidemantic import SemanticLayer, load_from_directory
layer = SemanticLayer(connection="duckdb:///data.duckdb")
load_from_directory(layer, "semantic_models/")
result = layer.query(
metrics=["orders.revenue"],
dimensions=["customers.region"]
)
Examples
See examples/ directory:
sql_query_example.py- SQL query interface demonstrationbasic_example.py- Core usage patternsmulti_format_demo/- Same model in different formats (Cube, Hex, LookML, BSL)
Testing
uv run pytest -v
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sidemantic-0.5.0.tar.gz.
File metadata
- Download URL: sidemantic-0.5.0.tar.gz
- Upload date:
- Size: 379.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
882edd6f56c3514d403a5a115431dc5cf0d341261ae4b76f95b1edbe575d7326
|
|
| MD5 |
e6babeae0cb698a456229c23df000da6
|
|
| BLAKE2b-256 |
61b2d1d544c9f9b7c8c979ecbcd8cec4741416c4075e85e76729d44a557f344a
|
File details
Details for the file sidemantic-0.5.0-py3-none-any.whl.
File metadata
- Download URL: sidemantic-0.5.0-py3-none-any.whl
- Upload date:
- Size: 245.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48629f5ff8d09dc6c9cf33847b64c8cb400d093a2a1c1e5cd3353640d3ec0729
|
|
| MD5 |
abe076043d1032609f1b7b0acab5ede3
|
|
| BLAKE2b-256 |
cad279df567fa1a8d4c77da39e1905d9ab29b70840b83088fd9c54c171a60bd1
|