> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# Semantic View YAML REST API

> Manage the database semantic views over REST using the database native YAML or OSI Core Metadata Spec YAML.

The database provides a REST API for managing **semantic views** using a human-readable YAML format. This API is an alternative to writing `CREATE SEMANTIC VIEW` DDL statements directly.

## Endpoints

| Method | Path | Description |
| - | - | - |
| `POST` | `/api/v2/catalogs/{catalog}/databases/{db}/semantic_views` | Create a semantic view from SQL DDL or a YAML body |
| `GET` | `/api/v2/catalogs/{catalog}/databases/{db}/semantic_views` | List published semantic views by default; use scope to include staging |
| `GET` | `/api/v2/catalogs/{catalog}/databases/{db}/semantic_views/{view}` | Get a semantic view definition (DDL/YAML), or its summary (`type=summary`) |
| `GET` | `/api/v2/catalogs/{catalog}/databases/{db}/semantic_views/{view}/{kind}` | Get the view's facts, metrics, dimensions, or their combined columns |
| `HEAD` | `/api/v2/catalogs/{catalog}/databases/{db}/semantic_views/{view}` | Check whether a semantic view exists (`200`/`404`, no body) |
| `DELETE` | `/api/v2/catalogs/{catalog}/databases/{db}/semantic_views/{view}` | Drop a semantic view |
| `POST` | `/api/v2/catalogs/{catalog}/databases/{db}/semantic_views/inline` | Return the inline (semantic-view-expanded) SQL of a query supplied in the body |
| `POST` | `/api/v2/catalogs/{catalog}/databases/{db}/semantic_views/merge_substrate` | Export the **merge substrate** of a semantic view supplied as DDL text, without creating anything |

Create/replace (`POST /semantic_views`) and drop (`DELETE /semantic_views/{view}`) requests sent to a non-leader FE return HTTP `307 Temporary Redirect`. The `Location` header points to the leader and preserves the escaped request path and query parameters. Native HTTPS requests redirect to HTTPS on `https_port`, which must be the same on all FEs; enable HTTPS on each FE. Follow the redirect with the same HTTP method and request body, and authenticate to the leader, or send the request directly to the leader. Read endpoints keep their existing routing.

### Path parameters

| Parameter | Description |
| - | - |
| `catalog` | The catalog name (use `default_catalog` for the internal catalog). |
| `db` | The database name. |
| `view` | The semantic view name. |
| `kind` | Metadata kind: `facts`, `metrics`, `dimensions`, or `columns`. |

### Query parameters

| Parameter | Applies to | Values | Description |
| - | - | - | - |
| `type` | POST `/semantic_views` | `sql` (default), `sr`, `osi` | Format of the request body. `sql` = a single `CREATE SEMANTIC VIEW` DDL statement; `sr` = the database native YAML; `osi` = OSI Core Metadata Spec YAML. |
| `replace` | POST `/semantic_views` | `true`, `false` (default) | For `type=sr`/`osi`, whether to replace an existing view of the same name. When omitted/`false`, creating a duplicate returns an error. |
| `scope` | GET `/semantic_views` | `published` (default), `temporary`, `all` | List visibility: published only by default, staging only, or both. Invalid values return HTTP 400. |
| `type` | GET `/{view}` | `sql` (default), `sr`, `osi`, `summary` | Format of the response. `sql` or omitted = original DDL SQL; `sr` = the database native YAML; `osi` = OSI Core Metadata Spec YAML; `summary` = JSON summary (name, comment, AI hints), the REST counterpart of `SHOW SEMANTIC VIEW {name}`. |

### Authentication

All endpoints use HTTP Basic authentication:

```shell theme={null}
-u '<username>:<password>'
```

## Temporary semantic views

`temporary` is a persistent staging flag, not a session lifetime. Collection GET accepts `scope=published|temporary|all`: omitted means `published` (non-temporary only), `temporary` returns staging views only, and `all` returns both. Invalid or empty scope returns HTTP 400. Every list entry and named `type=summary` response includes the boolean `temporary`.

A staging view remains accessible by name with the existing GET, HEAD, columns and DELETE APIs, and can be queried or expanded through `/inline` under ordinary authorization. `/validate` and `/merge_substrate` accept temporary definitions without creating them; the merge substrate also includes the submitted temporary flag.

For SQL POST, put `TEMPORARY` in `CREATE [OR REPLACE] TEMPORARY SEMANTIC VIEW`. SR YAML POST accepts a top-level `temporary: true|false`; omission means false. SR GET always exports the current flag. For OSI YAML, the existing model-level `custom_extensions` entry with `vendor_name: STARROCKS` carries a JSON string in `data`:

```yaml theme={null}
custom_extensions:
  - vendor_name: STARROCKS
    data: '{"temporary":true}'
```

OSI export writes the current true/false value and import restores it. An absent extension or the legacy `data: starrocks` means false; other vendors do not control this flag. The JSON `temporary` value must be a boolean. Exporting and importing either YAML format preserves staging. With `replace=true`, the submitted definition determines the resulting state; an omitted flag publishes the replacement. No ALTER endpoint is added.

## Get semantic-view columns

`GET /api/v2/catalogs/{catalog}/databases/{db}/semantic_views/{view}/{kind}`

Returns the complete metadata for one kind of semantic-view column. Set `kind` to `facts`, `metrics`, or `dimensions` to return only that kind. Set it to `columns` to return their union, ordered as facts, metrics, and then dimensions.

Every result object uses a common schema: `type`, `name`, `table`, `expression`, `access`, `filter`, `synonyms`, `comment`, `sampleValues`, `usingRelationships`, `nonAdditiveBy`, `window`, `searchService`, and `searchColumn`. Fields that do not apply to a particular kind are empty, `false`, or an empty array.

```shell theme={null}
curl 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/revenue_analysis/columns' \
  -u 'root:'
```

```json theme={null}
{
  "result": [
    {
      "type": "FACT",
      "name": "unit_price",
      "table": "orders",
      "expression": "unit_price",
      "access": "PUBLIC",
      "filter": false,
      "synonyms": ["price"],
      "comment": "Price per unit",
      "sampleValues": ["19.95"],
      "usingRelationships": [],
      "nonAdditiveBy": [],
      "window": false,
      "searchService": "",
      "searchColumn": ""
    }
  ]
}
```

## Create a semantic view

`POST /api/v2/catalogs/{catalog}/databases/{db}/semantic_views`

Creates a new semantic view from a request body. Omit `type` or set `type=sql` to submit a single `CREATE SEMANTIC VIEW` DDL statement. Set `type=sr` or `type=osi` to submit YAML, which is converted to a `CREATE SEMANTIC VIEW` statement internally. Creating a view whose name already exists returns an error; pass `replace=true` to overwrite it (`CREATE OR REPLACE SEMANTIC VIEW`).

### Request body

The request body is SQL DDL by default. For `type=sr`, the body is a YAML document describing the semantic view. Content-Type should be `text/plain`.

**YAML schema:**

```yaml theme={null}
name: <view_name>                    # Required. Name of the semantic view.
description: "<comment>"             # Optional. Human-readable description.
filter: "<boolean_expression>"      # Optional. View-level (global) filter applied to every query
                                     # against the view. Maps to the DDL "FILTER <expression>" clause.
                                     # e.g. "o_orderstatus = 'F'".

tables:                              # Required. One or more source tables.
  - name: <table_alias>             # Alias used to reference this table in expressions.
    description: "<table_comment>"  # Optional.
    base_table:
      database: <database_name>     # Database containing the physical table.
      table: <table_name>           # Physical table name.
    dimensions:                     # Optional. Categorical columns.
      - name: <dim_name>
        description: "<comment>"    # Optional.
        expr: <column_expression>   # SQL expression for this dimension.
        synonyms:                   # Optional. Alternative names for AI queries.
          - <synonym1>
          - <synonym2>
        sample_values:              # Optional. Representative example values (AI hint).
          - <value1>
          - <value2>
        labels:                     # Optional. Set to ["filter"] to mark as a filter dimension.
          - filter
    time_dimensions:                # Optional. Time-based dimensions (same structure as dimensions).
      - name: <dim_name>
        expr: <column_expression>
    facts:                          # Optional. Raw numeric measures (not aggregated).
      - name: <fact_name>
        expr: <column_expression>
        access_modifier: private_access  # Optional. Hides this fact from AI SQL generation.
        labels:                     # Optional. Set to ["filter"] to make this fact a reusable
          - filter                  # named filter (DDL "LABELS = (FILTER)").
    metrics:                        # Optional. Aggregated measures.
      - name: <metric_name>
        description: "<comment>"    # Optional.
        expr: <aggregate_expression>  # e.g. SUM(o_totalprice), COUNT(*)
        synonyms:                   # Optional.
          - <synonym>
        sample_values:              # Optional. Representative example values (AI hint).
          - <value1>
          - <value2>
        access_modifier: private_access  # Optional.

relationships:                      # Optional. Foreign-key joins between tables.
  - name: <relationship_name>
    left_table: <table_alias>
    right_table: <table_alias>
    join_type: INNER                # Optional. INNER or LEFT; omit to follow the session.
    relationship_columns:
      - left_column: <column>
        right_column: <column>

metrics:                            # Optional. View-level cross-table metrics.
  - name: <metric_name>
    description: "<comment>"
    expr: <expression_referencing_table_aliases>
```

### Response

| HTTP status | Description |
| - | - |
| 200 | View created successfully. |
| 400 | Request body is missing, contains invalid YAML, is not a `CREATE SEMANTIC VIEW` statement, or contains multiple SQL statements. |
| 500 | Internal error. |

**Success response body:**

```json theme={null}
{"code": "0", "message": "OK", "result": "created"}
```

**Error response body:**

```json theme={null}
{"code": "400", "message": "Invalid YAML: <details>"}
```

### Example

```shell theme={null}
curl -X POST 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views?type=sr' \
  -u 'root:' \
  -H 'Content-Type: text/plain' \
  -d '
name: revenue_analysis
description: "Revenue and customer analysis"
tables:
  - name: orders
    base_table:
      database: my_db
      table: orders
    dimensions:
      - name: order_date
        description: "Date the order was placed"
        expr: o_orderdate
        synonyms:
          - date
          - purchase date
    metrics:
      - name: total_revenue
        description: "Total revenue"
        expr: SUM(o_totalprice)
  - name: customers
    base_table:
      database: my_db
      table: customer
    dimensions:
      - name: customer_name
        expr: c_name
    metrics:
      - name: customer_count
        expr: COUNT(c_custkey)
relationships:
  - name: orders_to_customers
    left_table: orders
    right_table: customers
    relationship_columns:
      - left_column: o_custkey
        right_column: c_custkey
metrics:
  - name: revenue_per_customer
    description: "Average revenue per customer"
    expr: orders.total_revenue / orders.customer_count
'
```

## List semantic views

`GET /api/v2/catalogs/{catalog}/databases/{db}/semantic_views`

Returns summaries in the specified database according to `scope`; the default includes only published views.

### Response

**Success response body:**

```json theme={null}
{
  "code": "0",
  "message": "OK",
  "result": [
    {
      "name": "revenue_analysis",
      "comment": "Revenue and customer analysis",
      "aiSqlGeneration": null,
      "aiQuestionCategorization": null,
      "temporary": false
    }
  ]
}
```

### Example

```shell theme={null}
curl -X GET 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views' \
  -u 'root:'
```

## Get a semantic view

`GET /api/v2/catalogs/{catalog}/databases/{db}/semantic_views/{view}`

Returns the definition of a specific semantic view, either as DDL SQL (default) or as YAML.

### Response

#### Default (DDL SQL)

Returns the `CREATE OR REPLACE SEMANTIC VIEW` DDL statement as a JSON string:

```json theme={null}
{
  "code": "0",
  "message": "OK",
  "result": "CREATE OR REPLACE SEMANTIC VIEW my_db.revenue_analysis\n  TABLES (\n    ..."
}
```

#### The database YAML format (`?type=sr`)

Returns the view definition as plain YAML text (Content-Type: `text/plain`):

```yaml theme={null}
name: revenue_analysis
description: Revenue and customer analysis
tables:
  - name: orders
    baseTable:
      database: my_db
      table: orders
    dimensions:
      - name: order_date
        expr: o_orderdate
    metrics:
      - name: total_revenue
        expr: SUM(o_totalprice)
  ...
```

#### OSI format (`?type=osi`)

Returns the view definition as an [OSI Core Metadata Specification](https://github.com/open-semantic-interoperability/core-spec) (v0.1.1) YAML document (Content-Type: `text/plain`):

```yaml theme={null}
version: "0.1.1"
semantic_model:
  - name: revenue_analysis
    description: Revenue and customer analysis
    datasets:
      - name: orders
        source: my_db.orders
        fields:
          - name: order_date
            expression:
              dialects:
                - dialect: ANSI_SQL
                  expression: o_orderdate
    relationships:
      - name: orders_to_customers
        from: orders
        to: customers
        from_columns:
          - o_custkey
        to_columns:
          - c_custkey
    metrics:
      - name: total_revenue
        expression:
          dialects:
            - dialect: ANSI_SQL
              expression: SUM(o_totalprice)
```

| HTTP status | Description |
| - | - |
| 200 | View found and returned. |
| 404 | View not found. |

### Examples

Get as DDL:

```shell theme={null}
curl -X GET 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/revenue_analysis' \
  -u 'root:'
```

Or explicitly:

```shell theme={null}
curl -X GET 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/revenue_analysis?type=sql' \
  -u 'root:'
```

Get as the database YAML:

```shell theme={null}
curl -X GET 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/revenue_analysis?type=sr' \
  -u 'root:'
```

Get as OSI YAML:

```shell theme={null}
curl -X GET 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/revenue_analysis?type=osi' \
  -u 'root:'
```

## Get a semantic view summary

`GET /api/v2/catalogs/{catalog}/databases/{db}/semantic_views/{view}?type=summary`

Returns the single-view summary as JSON — the REST counterpart of `SHOW SEMANTIC VIEW {name}`. The fields mirror a row of `SHOW SEMANTIC VIEWS`. Returns `404` if the view does not exist.

```shell theme={null}
curl -X GET 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/revenue_analysis?type=summary' \
  -u 'root:'
```

```json theme={null}
{
  "code": 0,
  "message": "OK",
  "result": {
    "name": "revenue_analysis",
    "comment": "Revenue analysis semantic view",
    "aiSqlGeneration": "...",
    "aiQuestionCategorization": "..."
  }
}
```

## Check whether a semantic view exists

`HEAD /api/v2/catalogs/{catalog}/databases/{db}/semantic_views/{view}`

A lightweight existence check that returns `200` if the view exists and `404` otherwise, with no response body. Use `curl -I` (HEAD) rather than `curl -X HEAD`.

```shell theme={null}
curl -I 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/revenue_analysis' \
  -u 'root:'
```

## Drop a semantic view

`DELETE /api/v2/catalogs/{catalog}/databases/{db}/semantic_views/{view}`

Drops the specified semantic view. This operation uses `IF EXISTS` semantics and succeeds even if the view does not exist.

### Response

| HTTP status | Description |
| - | - |
| 200 | View dropped (or did not exist). |
| 500 | Internal error. |

**Success response body:**

```json theme={null}
{"code": "0", "message": "OK", "result": "dropped"}
```

### Example

```shell theme={null}
curl -X DELETE 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/revenue_analysis' \
  -u 'root:'
```

## Inline a query

`POST /api/v2/catalogs/{catalog}/databases/{db}/semantic_views/inline`

Returns the **inline SQL** of a query — the equivalent query where every semantic-view
reference has been expanded into its underlying base-table SQL (joins + aggregation). The
request body is the raw query. The `catalog`/`db` path segments provide the default
namespace for resolving unqualified view names.

The returned SQL is legal and directly executable (all identifiers are quoted). This is the
REST counterpart of [`EXPLAIN INLINE`](/documents/4.2/sql-reference/sql-statements/semantic-view/QUERY_SEMANTIC_VIEW#inspecting-the-inline-sql-explain-inline).

If the query references **no** semantic view, `inlineSql` equals the original query and
`referencesSemanticView` is `false`.

### Response

| Field | Description |
| - | - |
| `originalSql` | The query exactly as supplied. |
| `inlineSql` | The expanded SQL (equals `originalSql` when no semantic view is referenced). |
| `referencesSemanticView` | `true` if the query referenced at least one semantic view. |

```json theme={null}
{
  "code": 0,
  "message": "OK",
  "result": {
    "originalSql": "SELECT * FROM SEMANTIC_VIEW(my_db.order_metrics METRICS orders.total_price)",
    "inlineSql": "SELECT `order_metrics`.`total_price`\nFROM (SELECT SUM(`orders`.`o_totalprice`) AS `total_price` FROM `my_db`.`orders` AS `orders`) `order_metrics`",
    "referencesSemanticView": true
  }
}
```

### Example

```shell theme={null}
curl -X POST 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/inline' \
  -u 'root:' \
  -H 'Content-Type: text/plain' \
  -d 'SELECT * FROM SEMANTIC_VIEW(my_db.order_metrics METRICS orders.total_price)'
```

## Export a merge substrate

`POST /api/v2/catalogs/{catalog}/databases/{db}/semantic_views/merge_substrate`

Returns the **merge substrate** of a semantic view: everything an external tool needs in order
to decide whether two semantic views can be combined into one, and to write out the combined
definition. Nothing is created and no metadata is written — the semantic view is read from the
statement text, so it may be one that has never been created.

The request body is a single SQL script containing exactly one `CREATE SEMANTIC VIEW` and, in
any order, the `CREATE VIEW` statements it stands on. Statements are separated by semicolons.
Only the physical tables read by those views have to exist.

### What the substrate contains

| Field | Description |
| - | - |
| `format_version` | Substrate format version. |
| `semantic_view` | The parsed statement: tables, relationships, facts, dimensions, metrics, filter, and every comment, synonym and sample-value list on them. |
| `semantic_view.tables[].source` | Where the base table comes from: `script`, `catalog_view`, `catalog_table`, `absent` (no such object) or `unknown` (the lookup failed). |
| `logical_views[]` | One entry per logical view the semantic view depends on **directly** — whether this script supplied it or the catalog already holds it. |
| `logical_views[].source` | `script` when this script supplied the definition, `catalog` when it was read from an existing view. |
| `logical_views[].shadows_catalog` | Present on a `script` view whose name the catalog already holds. |
| `logical_views[].original_sql` | The view definition. |
| `logical_views[].norm` | Shape fingerprint. Two logical views can be combined only when these agree. |
| `logical_views[].normalized_sql` | The shared shape, with each differing projection written as a `{ph_N}` slot. |
| `logical_views[].columns[]` | Per output column: its name, the expression behind it, its slot, and whether it is a grouping column or a measure. |

A logical view supplied in the script may read physical tables and views that already exist in
the catalog. It may **not** read another logical view supplied in the same script: names inside
a view are resolved against the catalog rather than against the script, so the two would not be
the same definition. That case is rejected, naming both views.

When the script supplies a view whose name the catalog already holds, the script's definition
is the one exported, and `shadows_catalog` marks it so that whoever runs the combined script
knows the name is taken.

### Example

```shell theme={null}
curl -X POST 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views/merge_substrate' \
  -u 'root:' \
  -H 'Content-Type: text/plain' \
  --data-binary @my_semantic_view.sql
```

## Create a semantic view using OSI format

To create a semantic view from an OSI YAML body, add `?type=osi` to the POST request:

```shell theme={null}
curl -X POST 'http://<fe_ip>:<fe_http_port>/api/v2/catalogs/default_catalog/databases/my_db/semantic_views?type=osi' \
  -u 'root:' \
  -H 'Content-Type: text/plain' \
  -d '
version: "0.1.1"
semantic_model:
  - name: revenue_analysis
    description: "Revenue and customer analysis"
    datasets:
      - name: orders
        source: my_db.orders
        fields:
          - name: order_date
            expression:
              dialects:
                - dialect: ANSI_SQL
                  expression: o_orderdate
            ai_context:
              synonyms:
                - date
                - purchase date
      - name: customers
        source: my_db.customer
        fields:
          - name: customer_name
            expression:
              dialects:
                - dialect: ANSI_SQL
                  expression: c_name
    relationships:
      - name: orders_to_customers
        from: orders
        to: customers
        from_columns: [o_custkey]
        to_columns: [c_custkey]
    metrics:
      - name: total_revenue
        expression:
          dialects:
            - dialect: ANSI_SQL
              expression: SUM(o_totalprice)
        description: "Total revenue"
'
```

The OSI YAML is converted to a `CREATE OR REPLACE SEMANTIC VIEW` DDL statement internally before the view is created.

## The database native YAML format reference

The following table maps the database native YAML fields to the corresponding `CREATE SEMANTIC VIEW` DDL clauses:

| YAML field | DDL clause | Notes |
| - | - | - |
| `name` | View name in DDL | Required |
| `description` | `COMMENT = '...'` | View-level comment |
| `filter` | `FILTER <expression>` | View-level (global) filter applied to every query; emitted between `FACTS` and `DIMENSIONS` |
| `tables[].name` | Table alias in `TABLES (alias AS ...)` | |
| `tables[].base_table.database` | Database prefix in `TABLES (alias AS db.tbl)` | |
| `tables[].base_table.table` | Table name in `TABLES (alias AS db.tbl)` | |
| `tables[].description` | `COMMENT = '...'` after table alias | |
| `tables[].dimensions[]` | `DIMENSIONS (alias.name AS expr)` | |
| `tables[].time_dimensions[]` | `DIMENSIONS (alias.name AS expr)` | Merged with dimensions |
| `tables[].facts[]` | `FACTS (alias.name AS expr)` | |
| `tables[].metrics[]` | `METRICS (alias.name AS expr)` | |
| `relationships[].name` | Relationship name in `RELATIONSHIPS (name AS ...)` | |
| `relationships[].left_table` | Left table alias in `RELATIONSHIPS` | |
| `relationships[].right_table` | Right table alias `REFERENCES` target | |
| `relationships[].join_type` | `INNER` / `LEFT` keyword before `REFERENCES` | `INNER` or `LEFT`. Omitted means the relationship follows the session variable `enable_semantic_view_inner_join` |
| `relationships[].relationship_columns[].left_column` | Left join key column | |
| `relationships[].relationship_columns[].right_column` | Right join key column | |
| Top-level `metrics[]` | `METRICS` clause; table inferred from expression | |
| `synonyms` | `WITH SYNONYMS = (...)` | Per-column synonym list |
| `sample_values` | `SAMPLE_VALUES = (...)` | Per-column list of representative example values (facts, dimensions, metrics) used as AI hints |
| `labels: [filter]` | `LABELS = (FILTER)` | Marks a fact or dimension as a reusable named filter |
| `access_modifier: private_access` | `PRIVATE` keyword | Hides from AI SQL generation |

## OSI format reference

The following table maps OSI Core Metadata Specification (v0.1.1) fields to the database concepts:

| OSI field | the database equivalent | Notes |
| - | - | - |
| `semantic_model[0].name` | View name | Only the first model entry is used |
| `semantic_model[0].description` | View `COMMENT` | |
| `semantic_model[0].filter` | `FILTER <expression>` | View-level (global) filter (the database extension) |
| `semantic_model[0].datasets[]` | `TABLES` clause entries | |
| `dataset.name` | Table alias | |
| `dataset.source` | Physical table reference (`db.table`) | Supports 2-part (`db.table`) or 3-part (`cat.db.table`; last two parts used) |
| `dataset.primary_key` | `PRIMARY KEY` in `TABLES` clause | |
| `dataset.fields[]` | `DIMENSIONS` clause entries | |
| `field.dimension.is_time: true` | Time-based dimension | Placed in `time_dimensions` group; merged into `DIMENSIONS` |
| `field.expression.dialects[ANSI_SQL].expression` | Column expression | `ANSI_SQL` dialect preferred; first dialect used as fallback |
| `field.ai_context.synonyms[]` | `WITH SYNONYMS = (...)` | Array items become synonym strings |
| `field.labels: [filter]` | `LABELS = (FILTER)` | Marks a field as a reusable named filter (the database extension) |
| `semantic_model[0].relationships[]` | `RELATIONSHIPS` clause entries | |
| `relationship.from` / `relationship.to` | Left / right table aliases | |
| `relationship.from_columns[]` / `relationship.to_columns[]` | Join column pairs | Zipped positionally |
| `relationship.join_type` | `INNER` / `LEFT` keyword before `REFERENCES` | the database extension. `INNER` or `LEFT`. Omitted means the relationship follows the session variable `enable_semantic_view_inner_join` |
| `semantic_model[0].metrics[]` | `METRICS` clause entries | Model-level metrics; table attribution inferred from expression |
| `metric.expression.dialects[ANSI_SQL].expression` | Metric aggregate expression | |
| `metric.ai_context.synonyms[]` | `WITH SYNONYMS = (...)` | |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.