> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# Specify session variables for a Snowflake connection (Beta)

This documentation describes one or more public beta features that are in development. Beta features are subject to quick, iterative changes; therefore the current user experience in the Sigma service can differ from the information provided in this page.

This page should not be considered official published documentation until Sigma removes this notice and the beta flag on the corresponding feature(s) in the Sigma service. For the full beta feature disclaimer, see [Beta features](/docs/sigma-product-releases#beta-features).

You can set <a href="https://docs.snowflake.com/en/sql-reference/session-variables" target="_blank">session variables</a> on a Sigma connection to Snowflake. The session variables are set for each query that Sigma runs in Snowflake. For an example using session variables with a row access policy, see [Example implementation](#example-implementation).

## Requirements

* You must be assigned the Admin [account type](/docs/account-type-and-license-overview) or an account type with the **Manage connections** permission enabled.
* You must have an existing [Snowflake connection](/docs/connect-to-snowflake).
* (Optional) [Create a user attribute](/docs/user-attributes) to assign values of the variable to specific users or teams.

## Set session variables for a Snowflake connection

To set session variables for a Snowflake connection:

1. Open the Admin Portal by selecting **Administration** in the user menu at the top right of your screen.
2. In the left navigation, select **Connections**, then select the Snowflake connection.
3. On the connection overview, click **Edit**.
4. In the **Query variables** section, click **+ Add a query variable** to add one or more session variables as key-value pair mappings:

   1. For **Name**, enter the name of the session variable to set.
   2. Choose how to set the value of the variable:

      * To set one value of the variable for all users in Sigma, enter a value.
      * To set a different value of the variable for different users or teams in Sigma, turn on the **Set by user attribute** toggle, then select a user attribute.
5. (Optional) Repeat step 4 to add other variables.
6. Click **Save** to apply your changes.

## Example implementation

For example, set session variables used in <a href="https://docs.snowflake.com/en/user-guide/security-row-using" target="_blank">row access policies in Snowflake</a> using <a href="https://docs.snowflake.com/en/sql-reference/functions/getvariable" target="_blank">GETVARIABLE</a> syntax.

Given a row access policy definition like the following:

```sql
CREATE OR REPLACE ROW ACCESS POLICY secure_db.finance.profits AS (SALES_REGION VARCHAR) RETURNS BOOLEAN ->
    GETVARIABLE('REGION') IS NULL 
    OR SALES_REGION=GETVARIABLE('REGION');

ALTER TABLE SECURE_DB.FINANCE.PROFITS 
ADD ROW ACCESS POLICY SECURE_DB.FINANCE.PROFITS ON (SALES_REGION);
```

Set session variables on the Snowflake connection with the following details:

* Create a user attribute in Sigma to assign values of the variable to specific users or teams. For example, a `set_region` attribute with values `AMER` and `EU`.
* Add a session variable to the Snowflake connection with the name `REGION` and turn on the **Set by user attribute** toggle, then select the `set_region` attribute.

When a user assigned the `set_region` attribute with the `AMER` value queries the SECURE\_DB.FINANCE.PROFITS table from Sigma, they see only rows where the *SALES\_REGION* column has a value of `AMER`.

## Related resources

* [Connect to Snowflake](/docs/connect-to-snowflake)