DuckDB Semantic Views¶
A Semantic Layer sits between your raw tables and the people querying them. Instead of everyone writing their own SUM(amount) and hoping they GROUP BY the same columns, you define each metric and dimension once, in one place. Analysts pick the ones they want; the system assembles the SQL.
Snowflake and Databricks, along with dbt Cloud, Cube.dev and others, all ship semantic layers in different forms. Snowflake has Semantic Views, Databricks calls them Metric Views, both as a SQL syntax sugar for a special kind of flexible view-like interface over aggregated metrics and dimensions. This extension brings the same idea to DuckDB, using DDL syntax modeled closely on Snowflake’s CREATE SEMANTIC VIEW.
Install the extension, create your first semantic view, and run a query in 5 minutes.
Model relationships between tables and query across them.
Full syntax for CREATE SEMANTIC VIEW and related DDL.
FACTS, derived metrics, role-playing dimensions, fan traps, data sources.
Feature-by-feature comparison with Snowflake’s CREATE SEMANTIC VIEW.
Reference for semantic_view() and explain_semantic_view().