SnowPro Associate: Platform Question 159
Single answer● Understand contextA data engineering team at a retail company uses a worksheet to load sales data into Snowflake. The script contains unqualified object names, such as INSERT INTO daily_sales SELECT * FROM staging_sales;. A developer reports that the script succeeds in one session but fails in another with object not found errors, even though the tables exist. The team wants to understand how Snowflake resolves these object references and how to make execution consistent across sessions. Which action would most directly address the issue?
- A
Set the appropriate current database and current schema for the session before running the script, or fully qualify the object names
- B
Grant the developer the ACCOUNTADMIN role so Snowflake can locate objects regardless of session context
- C
Increase the warehouse size so metadata resolution completes successfully for unqualified object names
- D
Convert the tables to temporary tables so they are automatically resolved within each user session
Show answer and explanation
Correct answer: A
Explanation
This question tests understanding of Snowflake session context. In Snowflake, context includes the current role, warehouse, database, and schema. For object name resolution, the most relevant elements are the current database and current schema. When SQL statements use unqualified names such as daily_sales instead of MYDB.PUBLIC.daily_sales, Snowflake searches based on the active session context. As a best practice, teams should either set context explicitly at the start of scripts using USE ROLE, USE WAREHOUSE, USE DATABASE, and USE SCHEMA, or use fully qualified object names for clarity and portability. Snowflake documentation on sessions and object name resolution describes how current database and schema affect object references.
- A. Correct.
Correct. In Snowflake, unqualified object names are resolved using the current session context, especially the current database and current schema. If those differ between sessions, the same SQL can succeed in one session and fail in another. Setting the session context explicitly with commands such as
USE DATABASEandUSE SCHEMA, or using fully qualified names likedb.schema.table, makes execution predictable and consistent. - B. Incorrect.
Incorrect. Roles control privileges, not name resolution behavior. Even a highly privileged role does not remove the need for correct database and schema context when referencing unqualified object names. This option reflects the common misconception that broader privileges solve context-related object resolution issues.
- C. Incorrect.
Incorrect. Warehouse size affects compute resources for query execution, not how Snowflake resolves object names. Metadata and namespace resolution are independent of warehouse sizing. Someone might choose this if they confuse performance issues with object lookup behavior.
- D. Incorrect.
Incorrect. Temporary tables are session-specific objects, but converting permanent tables to temporary tables would not solve inconsistent resolution of existing unqualified object names across sessions. In fact, this could introduce new session-scope limitations and is unrelated to how current database and schema determine object lookup.