SnowPro Associate: Platform Question 31
Single answer● WorksheetsA data analyst is using a Snowsight worksheet to troubleshoot a transformation process. They first run USE ROLE ANALYST; and USE WAREHOUSE WH_XS;. Then they execute several SELECT statements successfully. Next, they highlight only the statement CALL ADMIN_DB.OPS.REBUILD_SUMMARY(); and run just that highlighted code. The procedure fails with an authorization error, even though the analyst expected the worksheet's earlier context to apply. What is the most likely explanation?
- A
When only highlighted SQL is run in a worksheet, Snowflake may execute just that selection, so earlier context-setting commands such as
USE ROLEare not re-executed for that run - B
Stored procedures cannot be executed from worksheets; they must be run from SnowSQL or the Classic Console
- C
A worksheet automatically resets the role to PUBLIC before every
CALLstatement for security reasons - D
Running highlighted SQL in a worksheet always re-runs all previously successful statements in the worksheet before executing the selection
Show answer and explanation
Correct answer: A
Explanation
This question tests practical worksheet behavior in Snowsight. A key point is that worksheets are session-based, but execution scope matters: running a highlighted statement executes only that selected SQL, not the entire worksheet history. As a result, context-setting commands like USE ROLE, USE WAREHOUSE, USE DATABASE, or USE SCHEMA must either already be active in the current session or be included in the selected code being run. This is a common real-world issue when users troubleshoot interactively and assume prior commands in the worksheet will automatically be replayed. Snowflake documentation for worksheets and SQL execution behavior emphasizes that users can run all statements, a single statement, or a selected portion, and the session context determines object resolution and privilege checks.
- A. Correct.
Correct. In Snowsight worksheets, execution depends on what the user runs. If the analyst highlights and runs only a specific statement, Snowflake executes that selection rather than replaying earlier worksheet statements. Session context such as role, warehouse, database, and schema must already be set in the current session or be included in the executed selection. If the required role was not active in the actual execution context, an authorization error can occur.
- B. Incorrect.
Incorrect. Stored procedures can be executed directly from Snowflake worksheets using the
CALLcommand, assuming the user has the required privileges and the procedure exists. This option reflects a common misconception that administrative or procedural SQL must be run only through command-line tools. - C. Incorrect.
Incorrect. Snowflake does not automatically switch the role to PUBLIC before each stored procedure call. Active role behavior is based on the session context and any explicit
USE ROLEcommand the user runs. The error is more likely due to the selected execution scope, not an automatic role reset. - D. Incorrect.
Incorrect. Highlighting and running SQL in a worksheet does not mean all prior statements are automatically re-executed. That misunderstanding often causes issues when users assume earlier
USEcommands or temporary setup statements will be applied again. In practice, only the selected statement or statements are run.