DAA-C01 Question 33
Single answerUse commands to read metadata and/or to alter context (e.g., DESCRIBE, SHOW, USE)A data analyst connects to Snowflake using a role that has access to multiple databases and schemas. They need to validate which schema is currently active before running an unqualified query against a table named SALES, and then inspect the columns and data types of that table in the active schema. Which sequence of commands best accomplishes this task with the least ambiguity?
- A
SHOW SCHEMAS; DESCRIBE TABLE SALES;
- B
USE SCHEMA ANALYTICS.PUBLIC; SHOW TABLES LIKE 'SALES';
- C
SELECT CURRENT_SCHEMA(); DESCRIBE TABLE SALES;
- D
SHOW DATABASES; USE DATABASE ANALYTICS; DESCRIBE VIEW SALES;
Show answer and explanation
Correct answer: C
Explanation
In Snowflake, object name resolution for unqualified names depends on the current database and schema context. To validate the current schema without altering the session context, CURRENT_SCHEMA() is the most direct and reliable choice. After confirming the active schema, DESCRIBE TABLE is the appropriate command to inspect a table's metadata, including column names and data types. SHOW commands are useful for listing objects, but they do not by themselves confirm the active context. USE commands alter context, which is valuable when you intend to switch databases or schemas, but they do not answer the question of what the current context already is. This aligns with Snowflake best practices for avoiding accidental queries against the wrong schema when multiple databases and schemas are accessible.
- A. Incorrect.
Incorrect. SHOW SCHEMAS lists schemas that are available in the current or specified database, but it does not directly confirm which schema is currently active for the session. DESCRIBE TABLE SALES would then rely on the current context, which remains ambiguous if the analyst has not explicitly checked or set it. This option reflects the common misconception that listing available schemas is the same as identifying the active schema.
- B. Incorrect.
Incorrect. USE SCHEMA ANALYTICS.PUBLIC explicitly sets the schema context, which can be useful, but the scenario asks the analyst to validate which schema is currently active before running an unqualified query. This option changes the context rather than validating the existing one. SHOW TABLES LIKE 'SALES' can confirm that a table exists in the current schema, but it does not provide the table's column definitions and data types.
- C. Correct.
Correct. SELECT CURRENT_SCHEMA(); verifies the active schema in the session without changing context. DESCRIBE TABLE SALES; then returns metadata about the SALES table, including column names, data types, nullability, and related details, assuming SALES resolves in the active schema. This is the least ambiguous approach because it first confirms the current schema and then inspects the table definition in that context.
- D. Incorrect.
Incorrect. SHOW DATABASES only lists databases visible to the current role and does not identify the current schema. USE DATABASE ANALYTICS changes only the database context, not necessarily the schema, so an unqualified reference could still be ambiguous if the current schema is not what the analyst expects. DESCRIBE VIEW SALES is also the wrong object type unless SALES is actually a view rather than a table.