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

# canonic sl

> Semantic layer: resolve, compile, and describe.

`canonic sl` exposes the semantic-layer capabilities directly: useful for debugging what a metric resolves to or what SQL a query compiles down to, without executing anything.

<Note>
  With `--json`, each of these commands' output matches its corresponding MCP tool payload byte-for-byte (`resolve_metric`, `compile_query`, `describe_metric`).
</Note>

## `sl resolve`

Resolve a name to its canonical binding.

```bash theme={null}
canonic sl resolve revenue
canonic sl resolve revenue --context finance_review
```

| Argument / Flag | Description                                  |
| --------------- | -------------------------------------------- |
| `name`          | Metric/dimension name (positional).          |
| `--context`     | Tag for context-scoped guardrail resolution. |

Prints the resolved metric, owning source, measure, and binding kind.

## `sl compile`

Compile a semantic query to SQL + metadata without executing it.

```bash theme={null}
canonic sl compile --metrics revenue --dimensions order_date
canonic sl compile --file query.json
```

| Flag           | Description                                                 |
| -------------- | ----------------------------------------------------------- |
| `--metrics`    | Metric name(s): comma-separated and/or repeatable.          |
| `--dimensions` | Dimension name(s): same comma/repeat rules as `--metrics`.  |
| `--filter`     | A filter as `field=value` or `field:op:value` (repeatable). |
| `--file`, `-f` | Semantic query JSON file.                                   |

`--metrics`/`--dimensions`/`--filter` and `-f` are mutually exclusive, same as `canonic query`; see [`canonic query`](/cli-reference/query-sql-assert) for the full filter syntax. The flags build the identical `SemanticQuery` a JSON file would deserialize: `{"metrics": [...], "dimensions": [...], "filters": [...], "limit": null}`. Output includes the target dialect, the compiled SQL, resolved bindings, and any guardrails that fired.

## `sl describe`

Return grain, dimensions, measures, and freshness for one metric.

```bash theme={null}
canonic sl describe revenue
```

| Argument | Description                        |
| -------- | ---------------------------------- |
| `name`   | Metric name or alias (positional). |

Prints the metric's source, grain, dimensions, freshness (`last_validated_at`), and any worked examples on file.
