DAA-C01 Question 34
Single answerUse commands to read metadata and/or to alter context (e.g., DESCRIBE, SHOW, USE)A data analyst is troubleshooting why a BI worksheet is returning results from an unexpected schema. The analyst is connected to Snowflake and wants to verify the current session context, inspect what tables exist in the intended schema, and then switch the session so unqualified object names resolve correctly. Which sequence of commands best accomplishes this goal?
- A
SELECT CURRENT_DATABASE(), CURRENT_SCHEMA(); SHOW TABLES IN SCHEMA FINANCE.RAW; USE SCHEMA FINANCE.ANALYTICS;
- B
DESCRIBE DATABASE FINANCE; DESCRIBE SCHEMA RAW; ALTER SESSION SET SCHEMA = ANALYTICS;
- C
SHOW SCHEMAS LIKE 'ANALYTICS' IN DATABASE FINANCE; DESCRIBE TABLE FINANCE.RAW.SALES; USE TABLE FINANCE.ANALYTICS.SALES;
- D
SHOW TABLES; DESCRIBE TABLES IN SCHEMA FINANCE.RAW; SET SCHEMA = FINANCE.ANALYTICS;
Show answer and explanation
Correct answer: A
Explanation
This question tests applied use of Snowflake metadata and context commands in a realistic troubleshooting scenario. In Snowflake, session context determines how unqualified object names are resolved, so verifying the active database and schema is often the first step. CURRENT_DATABASE() and CURRENT_SCHEMA() are commonly used to confirm current context. SHOW commands are used to list metadata objects such as databases, schemas, and tables, for example SHOW TABLES IN SCHEMA
- A. Correct.
Correct. CURRENT_DATABASE() and CURRENT_SCHEMA() are appropriate for confirming the active session context. SHOW TABLES IN SCHEMA FINANCE.RAW is a valid metadata command to inspect table objects in a specific schema. USE SCHEMA FINANCE.ANALYTICS correctly changes the current schema so that subsequent unqualified object references resolve within that schema. This sequence directly addresses verification, inspection, and context switching.
- B. Incorrect.
Incorrect. DESCRIBE DATABASE and DESCRIBE SCHEMA return metadata about those objects, but they do not tell the analyst the current session database/schema being used for name resolution. More importantly, ALTER SESSION SET SCHEMA = ANALYTICS is not the standard way to change the current schema context in Snowflake; USE SCHEMA is the correct command for setting the active schema.
- C. Incorrect.
Incorrect. SHOW SCHEMAS LIKE 'ANALYTICS' IN DATABASE FINANCE can help confirm that the schema exists, and DESCRIBE TABLE on a fully qualified table is valid for table metadata. However, USE TABLE is not a valid Snowflake command because session context can be set for roles, warehouses, databases, and schemas, not individual tables. This option does not correctly alter context for object resolution.
- D. Incorrect.
Incorrect. SHOW TABLES is valid, but without an IN clause it may not target the intended scope clearly. DESCRIBE TABLES IN SCHEMA is not valid Snowflake syntax; DESCRIBE is used on a specific object, while SHOW TABLES lists objects. SET SCHEMA = FINANCE.ANALYTICS is also not the correct command for changing schema context in Snowflake; USE SCHEMA should be used instead.