Skip to content

Allow a default dialect at the semantic model level #294

Description

@fanruan-tuco

Problem

Most models use the same dialect for nearly every field and metric, so this gets repeated throughout the file:

expression:
  dialects:
    - dialect: ANSI_SQL
      expression: SUM(orders.amount)

The repetition makes otherwise simple models harder to read and maintain.

Proposal

Allow a semantic model to declare a default dialect and use a string shorthand for expressions:

semantic_model:
  - name: sales
    default_dialect: ANSI_SQL
    datasets:
      - name: orders
        source: analytics.orders
        fields:
          - name: amount
            expression: amount
    metrics:
      - name: revenue
        expression: SUM(orders.amount)

Explicit dialects would still be supported when an expression needs an override:

expression:
  dialects:
    - dialect: ANSI_SQL
      expression: DATE_TRUNC('month', orders.created_at)
    - dialect: SNOWFLAKE
      expression: DATE_TRUNC('MONTH', orders.created_at)

Existing files would remain valid unchanged. The shorthand would only be allowed when default_dialect is present.

This is related to #52, but takes a smaller, backward-compatible approach: it keeps per-expression dialect overrides and scopes the default to each semantic model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions