Semantic model

The semantic model is OneAnalytics' business-friendly layer over your raw tables. Dimensions, measures, and joins live in one YAML document per dataset. Every report, AI question, and alert resolves against this model — never against raw SQL.

Anatomy

dataset: sales_cube
source: { type: postgres, ref: warehouse }
tables:
  - name: orders
    primary_key: id
  - name: customers
    primary_key: id
joins:
  - left: orders.customer_id
    right: customers.id
    kind: many_to_one
dimensions:
  - id: region
    column: customers.region
    label: Region
  - id: order_date
    column: orders.created_at
    type: date
    grains: [day, week, month, quarter, year]
measures:
  - id: revenue
    type: sum
    column: orders.net_amount
  - id: aov
    type: ratio
    numerator: revenue
    denominator: order_count

Why it matters

  • One source of truth. Every report calls revenue. When the CFO changes the definition to exclude cancellations, you edit one line and every report, card, and AI answer updates.
  • AI quality. The NL-to-query engine only sees entity labels, not column names. "revenue by region last quarter" is unambiguous because revenue and region are declared.
  • Security boundary. Row-level security rules attach to dimensions — region = {{ user.region }} applies to every query that touches the region dimension.

Time grain

Time dimensions declare the grains they support. A report that asks for month grain receives date_trunc('month', orders.created_at) in Postgres, DATE_TRUNC('MONTH', orders.created_at) in Snowflake. Dialect differences are handled by the compiler.

Ratios and derived measures

- id: gross_margin_pct
  type: ratio
  numerator: { type: sum, column: orders.gross_profit }
  denominator: revenue
  format: percent

Ratios are computed post-aggregation — never as AVG(col) — so they stay correct under any filter.

Editing

Open a dataset, click Model tab, edit YAML, click Validate. The validator checks that every column resolves, every join keys exist, and no cycle exists in the derived-measure DAG. Invalid models never save.