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
alter_semantic_view_rename table NULL NULL  
alter_semantic_view_rename_if_exists table NULL NULL  
alter_semantic_view_set_comment table NULL NULL  
alter_semantic_view_set_comment_if_exists table NULL NULL  
alter_semantic_view_unset_comment table NULL NULL  
alter_semantic_view_unset_comment_if_exists table NULL NULL  
create_or_replace_semantic_view_from_json table NULL NULL  
create_semantic_view_from_json table NULL NULL  
create_semantic_view_if_not_exists_from_json table NULL NULL  
describe_semantic_view table NULL NULL  
drop_semantic_view table NULL NULL  
drop_semantic_view_if_exists 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  
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_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.