Semantic Datasets
A dataset is a reusable semantic layer over one or more tables — you name the dimensions, metrics, and filters once, and every chart, dashboard, and NL→SQL query builds on them without re-writing SQL.
Why a semantic layer
Raw tables don’t know which columns are things to group by and which are things to measure. A dataset encodes that intent once: dimensions (categories, dates), metrics (aggregations), and filterable columns. Charts then reference the dataset, and Kaveon generates the correct SELECT, JOIN,GROUP BY, and aggregation for you.
Anatomy of a dataset
| Part | Stored in | Purpose |
|---|---|---|
| Fact table + joins | datasets | The base table and any related tables to join |
| Dimensions | dataset_dimensions | Group-by columns (strings, dates) |
| Metrics | dataset_metrics | Aggregations — e.g. SUM(total), COUNT(*), AVG(price) |
| Columns | dataset_columns | The resolved column list used for filters and previews |
Creating a dataset
- Go to Datasets → + New Dataset and pick a data source.
- Choose a fact table; add related tables and their join keys if you need more than one.
- Mark each column as a dimension or a metric (with its aggregation).
- Preview, then save. It’s now available to every chart and the NL→SQL engine.
Automatic SQL generation
When a chart requests dimensions and metrics, the query_generator service assembles the star-schema SQL — selecting the dimensions, applying each metric’s aggregation, generating the JOINs from the dataset definition, and grouping/ordering appropriately.
-- "revenue by region" against a dataset with
-- dimension: region metric: SUM(total) AS revenue
SELECT d.region, SUM(f.total) AS revenue
FROM fact_orders f
JOIN dim_region d ON d.id = f.region_id
GROUP BY d.region
ORDER BY revenue DESC; COALESCE-based resolution so each role maps to the right join without duplicating the dataset.Visibility
Datasets — like charts and dashboards — carry a visibility level: private (only you), internal (signed-in users), or published. Combined with the role model (see Auth & RBAC), this controls who can discover and build on each dataset.