# Si writes and runs SQL/Python

> For exploratory questions that go beyond the ready-made metrics (medians, percentiles, correlations, joining two tables, custom charts), Si writes SQL or Python and runs it in an isolated sandbox. Results are always Unconfirmed.

Most questions are answered from **metrics** and the **semantic layer** — **Standard** or **Approved** numbers that match your
dashboards. When a question goes beyond the metrics you have, Si can **write its own SQL or Python** and run it in the
**exploration sandbox**. It's a tool for analysis, not a replacement for official metrics.

## When Si uses the sandbox

| Question | Si uses |
| --- | --- |
| Revenue, profit, orders, return rate; versus last period; top N; "why did it drop" | Metrics and the semantic layer (Standard numbers) |
| Median, percentiles, order-value distribution | Sandbox (SQL) |
| Correlation between daily ad spend and revenue | Sandbox (SQL or Python) |
| Joining two tables on a key the model doesn't have yet | Sandbox (SQL) |
| Monthly cohorts, simple regression, custom charts | Sandbox (Python) |

Si always tries the semantic layer first. It never uses the sandbox to recompute a metric that already exists.

## Confirmation level: always "Unconfirmed"

Every number computed in the sandbox carries the **Unconfirmed** label: the code was written by Si and nobody has
checked the definition yet. The answer states its confirmation level, and each run gets a card under the answer
with:

- the **Unconfirmed** label;
- **View SQL code / View Python code** (collapsed) - read it to see how Si computed the result;
- the result table (up to 100 rows), charts (up to 2) and printed output.

Sandbox results **can't** be pinned as dashboard tiles and **can't** be saved as a "confirmed answer". To keep something for the
long run:

1. **Save draft to knowledge** (code included) so a reviewer can read it; or
2. ask Si to **save it as a metric** — Si creates a draft metric on the semantic model, and a reviewer checks the numbers before
   turning it on (see [Workspace metrics](/en/docs/metrics/workspace-metrics)).

## What the sandbox can read

- Only **published** data (the same version your dashboards show), the **core** and **marts** layers. No raw data (`raw`) or
  intermediate layers.
- **No personal data**: columns such as phone numbers, emails, buyer names, hashed columns and customer identifiers are removed
  before the data reaches the sandbox. To count customers, Si uses the semantic layer.
- A read-only copy: code can't write to the workspace's data, metrics or configuration.

## Security

- Code runs in a **separate sandbox service** with no network, no access to files outside the run's temporary folder, and no keys
  or passwords. Each run is capped: 30 seconds, a memory limit, 200 result rows for Si.
- SQL must be **a single read statement** (SELECT); statements that write, read files or change settings are rejected before
  they run.
- Every run is recorded in the audit log: the **code** and the **number of result rows** (data values are not logged).

## Who can use it

- The **Analyst**, **Admin** and **Owner** roles. The **Viewer** role can't.
- The **Small Business** plan and above (see [Plans and limits](/en/docs/billing/quotas)). Each run counts as **1 extra Si
  question**.
- Up to 4 runs per question and 20 runs per minute per person.
- Web app only. Questions through Telegram, Slack or Teams don't use the sandbox.
- Over MCP: only tokens granted the extra `explore:run` scope (off by default); see [MCP](/en/docs/mcp).

## FAQ

**Why does a sandbox number differ from the dashboard?** Si's code may filter or group differently from the metric definition
(for example, including cancelled orders). Open "view code" to see how it was computed; the official number is still the one on
the dashboard.

**Si says the exploration sandbox is not enabled?** Your server isn't running the sandbox service;
contact your administrator (self-hosted deployments).

**Si says you're out of questions?** Each run counts towards the month's Si questions; buy a 500-question pack or upgrade your
plan.
