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

# Snowflake

> Read-only SQL across your databases, plus query history and telemetry.

Connect Snowflake so Struct Agent can run read-only queries and inspect the permitted query history and telemetry. Verify the intended account, role and data scope.

## Inspect access and existing connections

Use a claimed workspace with permission to configure connections.

```bash theme={null}
struct whoami --json
struct connections catalog snowflake --json
struct connections list --json
```

Use the catalog's current fields, choices and permission requirements. Reuse an existing healthy connection instead of creating a duplicate.

## Connect with the CLI

Print the setup material first:

```bash theme={null}
struct connect snowflake --print-commands --account myorg-myaccount --user STRUCT_READER --warehouse COMPUTE_WH
```

An authorized operator runs the generated provider commands after checking the account and scope. Printing them does not apply grants. Preserve generated identifiers (such as an AWS External ID or Snowflake key-pair ID), then run the returned connection command with the real values.

Each connection needs its own service user. The generated setup SQL includes only the public key; Struct keeps the private key. Run all setup statements with an authorized Snowflake admin, then use the printed `sfk_…` key-pair ID within 24 hours. If a grant is missing, apply it and retry with the same key pair.

For rotation, `struct connections rotate CONNECTION_ID --print-commands` creates a new public key for the unused key slot. Apply that SQL, then run `struct connections rotate CONNECTION_ID --key-pair KEY_PAIR_ID`. Verify the old fingerprint before removing its key slot. Preserve the user's other key.

## Verify and recover

Use the returned connection ID:

```bash theme={null}
struct connections show CONNECTION_ID --json
struct connections test CONNECTION_ID --json
```

Inspect `ok`, `health` and missing permissions, not only the exit code. `struct connections grant-command CONNECTION_ID` prints repair instructions where supported; have an authorized operator apply them. For expired OAuth links, start the connection command again and use the new link. Do not reconnect to a different account silently.

Verify a bounded operation for the requested job. Connection health proves checked access; it does not prove telemetry arrival, an investigation or alert delivery.

## What Struct reads

* **Event tables.** Logs, traces, and metrics from stored procedures, UDFs, Snowpark, tasks, and dynamic tables.
* **Query history.** Failed loads, pipeline errors, and slow queries from the last 7 days.
* **Read-only SQL** against the tables you grant.

## Permissions

The service user's role needs SNOWFLAKE.EVENTS\_VIEWER, USAGE on one warehouse, and SELECT on the databases Struct should read. MONITOR on that warehouse lets Struct see queries other users ran on it; the setup SQL grants it too.

### Read-only queries and telemetry

Read event-table logs, traces and metrics, query history, and the tables you grant.

| Grant | Used for |
| - | - |
| `SNOWFLAKE.EVENTS_VIEWER` | Event tables from stored procedures, UDFs, Snowpark, tasks and dynamic tables |
| `USAGE ON WAREHOUSE` | Running queries on one warehouse |
| `SELECT` | Tables and views in the databases you grant, including ones created later |

### Other users' query history

Only needed to see queries that other users and roles ran on the warehouse. Without it, `INFORMATION_SCHEMA.QUERY_HISTORY` returns only the service user's own queries.

| Grant | Used for |
| - | - |
| `MONITOR ON WAREHOUSE` | Query history on that warehouse. It does not let Struct start, stop, resize or use the warehouse (that is OPERATE or USAGE) |

* The setup SQL Struct generates grants SELECT across your current standard databases. If you create a database later, re-run its `EXECUTE IMMEDIATE` block, or grant it on its own with the commands below.

### How to grant

> [accordion] Grant one database
>
> ```sql theme={null}
> GRANT APPLICATION ROLE SNOWFLAKE.EVENTS_VIEWER TO ROLE STRUCT_READER_ROLE;
> GRANT USAGE ON WAREHOUSE COMPUTE_WH TO ROLE STRUCT_READER_ROLE;
> GRANT MONITOR ON WAREHOUSE COMPUTE_WH TO ROLE STRUCT_READER_ROLE;
> GRANT USAGE ON DATABASE <database> TO ROLE STRUCT_READER_ROLE;
> GRANT USAGE ON ALL SCHEMAS IN DATABASE <database> TO ROLE STRUCT_READER_ROLE;
> GRANT SELECT ON ALL TABLES IN DATABASE <database> TO ROLE STRUCT_READER_ROLE;
> GRANT SELECT ON ALL VIEWS IN DATABASE <database> TO ROLE STRUCT_READER_ROLE;
> GRANT USAGE ON FUTURE SCHEMAS IN DATABASE <database> TO ROLE STRUCT_READER_ROLE;
> GRANT SELECT ON FUTURE TABLES IN DATABASE <database> TO ROLE STRUCT_READER_ROLE;
> GRANT SELECT ON FUTURE VIEWS IN DATABASE <database> TO ROLE STRUCT_READER_ROLE;
> ```

Replace the values in angle brackets.

Permission catalog version `2026-11-04.1`. See [permission changes](https://docs.struct.ai/reference/permission-changes.md).


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