Parameters, Precedence, and Session Context
SnowPro Core · Lesson 4 of 27 · 19:52
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the SnowPro Core Certification exam (COF-C03). In this lesson: the three kinds of parameters, levels and precedence, session variables, and context functions. Follows Foxglove Apparel, a fictional online clothing retailer. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Settings at every level
Foxglove's account shows times in Los Angeles time, but its London team wants London time. Last week, one forgotten query also ran for hours on a dashboard warehouse. Both problems are fixed with parameters, set at the right level.
Three kinds of parameters
Parameters control how Snowflake behaves, and each one has a default value. Account parameters are set only at the account level, with ALTER ACCOUNT, by a role that holds the privilege, like the network policy of the account. Session parameters control a user's session, such as the time zone, a query tag, or a statement timeout. And object parameters apply to objects, such as the Time Travel retention of a table, or the statement timeout of a warehouse.
Levels and precedence
Session parameters can be set for the account, for a user, and for the current session, with ALTER ACCOUNT, ALTER USER, and ALTER SESSION. Object parameters can be set for the account, then overridden on a database, a schema, or a table. The most specific level wins: the session overrides the user, and the user overrides the account, while a table overrides its schema and its database. And SHOW PARAMETERS lists each value, with the level where it was set.
Session variables
A session variable stores a value for the length of a session, and the SET command creates it. You reference it with a dollar sign, for example dollar target, inside any statement. With the IDENTIFIER keyword, a variable can even hold an object name, like the table that a script should read. The variable disappears when the session ends, or when you run UNSET.
Context functions
Context functions return facts about the session, such as CURRENT_USER, CURRENT_ROLE, CURRENT_WAREHOUSE, CURRENT_DATABASE, and CURRENT_SCHEMA. The USE commands change that context: USE ROLE, USE WAREHOUSE, USE DATABASE, and USE SCHEMA. Context functions also appear inside policies and secure views, where the current role decides what a user can see. And CURRENT_DATE and CURRENT_TIMESTAMP are context functions too.
Parameters you meet often
A few parameters come up often. STATEMENT_TIMEOUT_IN_SECONDS cancels statements that run too long, and you can set it on a warehouse as well as for a session. QUERY_TAG labels every query of a session, which helps you attribute costs to a team or a job. And DATA_RETENTION_TIME_IN_DAYS sets how long Time Travel keeps old data, for the account, a database, a schema, or a table.
Foxglove's settings
Here is what Foxglove sets. The account keeps Los Angeles as the default time zone, and the London users override it on their users. The dashboard warehouse gets a statement timeout of ten minutes, so a forgotten query is cancelled. And each loading job sets its own query tag, so finance can see what each job costs.
Recap
Let's recap. Parameters come in three kinds: account, session, and object parameters. Session parameters go from the account, to the user, to the session, and object parameters go from the account down to a table. The most specific level wins, and SHOW PARAMETERS tells you where each value comes from. Session variables are set with SET and read with a dollar sign, and IDENTIFIER turns one into an object name. And context functions like CURRENT_ROLE return facts about the session.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
The account sets the time zone to Los Angeles, and the user Priya has London set on her user. In her session, she then sets it to UTC. Which time zone applies to her queries?
- Los Angeles, from the account
- London, from her user
- A mix, chosen for each query
- UTC, from her session
Show the answer
UTC, from her session
The session level is the most specific, so U T C applies for the rest of her session. “Los Angeles, from the account” is the account default, which both other levels override. “London, from her user” would apply in her next session, unless she changes it again. And “A mix, chosen for each query” is wrong, since one value applies at a time.
A Foxglove script runs the same statements against a test table or the production table, and the table is chosen once, at the start of the script. What fits?
- A sequence that numbers each run
- SET a variable, then IDENTIFIER($target)
- An account parameter that holds the name
- The CURRENT_SCHEMA() context function
Show the answer
SET a variable, then IDENTIFIER($target)
SET stores the table name in a session variable, and IDENTIFIER turns it into an object name in each statement. “A sequence that numbers each run” only generates numbers, and names no tables. “An account parameter that holds the name” would change the setting for everyone in the account. And “The CURRENT_SCHEMA() context function” only reads the current schema, and cannot choose between two tables.
Foxglove’s finance team wants to see which pipeline job ran each query, so it can split warehouse costs by job. Which parameter should each job set in its session?
- QUERY_TAG
- TIMEZONE
- USE_CACHED_RESULT
- DATA_RETENTION_TIME_IN_DAYS
Show the answer
QUERY_TAG
QUERY_TAG labels each query in the session, and the label shows up in the query history for cost reporting. “TIMEZONE” only changes how times are shown. “USE_CACHED_RESULT” controls whether cached results are reused, not how queries are labeled. And “DATA_RETENTION_TIME_IN_DAYS” sets Time Travel retention, which has nothing to do with labels.