
Answer-first summary for fast verification
Answer: When the procedure is defined to execute as CALLER.
User session variables can only be accessed in Snowflake stored procedures when the procedure is defined with CALLER rights (EXECUTE AS CALLER). This is because CALLER rights execute the procedure with the privileges and session context of the user calling the procedure, allowing access to their session variables. In contrast, OWNER rights execute with the privileges of the procedure owner, which does not have access to the caller's session variables. The STRICT option relates to NULL handling in arguments, not session variable access. Arguments with the same name and type as session variables are separate parameters and do not enable session variable access. The community discussion confirms this with 100% consensus on option B and references to Snowflake documentation supporting this behavior.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
In what contexts can user session variables be accessed within a Snowflake stored procedure?
A
When the procedure is defined as STRICT.
B
When the procedure is defined to execute as CALLER.
C
When the procedure is defined to execute as OWNER.
D
When the procedure is defined with an argument that has the same name and type as the session variable.
No comments yet.