Search Shortcut cmd + k | ctrl + k
semantic_views

Semantic views – a declarative layer for dimensions, metrics, and relationships

Maintainer(s): anentropic

Installing and Loading

INSTALL semantic_views FROM community;
LOAD semantic_views;

Example

-- Create sample data
CREATE TABLE demo(region VARCHAR, amount DECIMAL(10,2));
INSERT INTO demo VALUES ('US', 100), ('US', 200), ('EU', 150);

-- Define a semantic view
CREATE SEMANTIC VIEW sales AS
  TABLES (d AS demo PRIMARY KEY (region))
  DIMENSIONS (d.region AS d.region)
  METRICS (d.revenue AS SUM(d.amount));

-- Query it
FROM semantic_view('sales', dimensions := ['region'], metrics := ['revenue']);

About semantic_views

Semantic views let you define dimensions, metrics, joins, and filters once, then query any combination. The extension handles GROUP BY, JOIN, and filter composition automatically. Supports multi-table joins with PK/FK relationships, fan trap detection, role-playing dimensions, derived metrics, and FACTS.

Documentation: https://anentropic.github.io/duckdb-semantic-views/

Added Functions

function_name function_type description comment examples
describe_semantic_view table NULL NULL  
explain_semantic_view table NULL NULL  
get_ddl scalar NULL NULL  
list_semantic_views table NULL NULL  
list_terse_semantic_views table NULL NULL  
read_yaml_from_semantic_view scalar NULL NULL  
semantic_view table NULL NULL  
show_columns_in_semantic_view table NULL NULL  
show_semantic_dimensions table NULL NULL  
show_semantic_dimensions_all table NULL NULL  
show_semantic_dimensions_for_metric table NULL NULL  
show_semantic_facts table NULL NULL  
show_semantic_facts_all table NULL NULL  
show_semantic_materializations table NULL NULL  
show_semantic_materializations_all table NULL NULL  
show_semantic_metrics table NULL NULL  
show_semantic_metrics_all table NULL NULL  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

This extension does not add any settings.