SnowPro Associate: Platform Question 232
Single answer○ LISTA data engineer needs to verify which files are currently available in an external stage before running a COPY INTO command. The stage points to an Amazon S3 bucket and contains thousands of objects across multiple prefixes. The engineer wants to quickly inspect only files under the path daily/sales/ whose names start with 2024_01. Which Snowflake command is the most appropriate to use?
- A
SELECT * FROM @ext_stage/daily/sales/ WHERE METADATA$FILENAME LIKE '2024_01%';
- B
LIST @ext_stage/daily/sales/ PATTERN='.2024_01.';
- C
GET @ext_stage/daily/sales/ file://tmp PATTERN='2024_01.*';
- D
DESCRIBE STAGE @ext_stage/daily/sales/ PATTERN='2024_01.*';
Show answer and explanation
Correct answer: B
Explanation
For inspecting files in a stage, Snowflake provides the LIST command (or its alias LS). LIST works with both internal and external stages and supports an optional path plus a PATTERN regular expression to narrow results. This makes it the correct command when an engineer wants to confirm which files are available before running COPY INTO. By contrast, GET is for downloading from internal stages, and DESCRIBE STAGE shows stage metadata rather than file contents. Snowflake documentation for staged data operations and stage management identifies LIST as the appropriate command for enumerating files in a stage.
- A. Incorrect.
Incorrect. Querying staged files with a SELECT statement is only applicable for reading supported file contents through stage references, not for listing the inventory of files available in a stage. Although metadata columns such as METADATA$FILENAME can be used when selecting from staged data files, this does not serve as the primary mechanism to enumerate stage contents before loading.
- B. Correct.
Correct. The LIST command is designed to return files available in an internal or external stage. Specifying the stage path
@ext_stage/daily/sales/narrows the search to that virtual folder, and the PATTERN parameter can further filter matching file names using a regular expression. This is the standard way to inspect staged files before a load operation. - C. Incorrect.
Incorrect. GET downloads files from an internal stage to a local filesystem; it is not used to inspect file names in an external stage. In addition, GET does not apply to external stages such as Amazon S3 stages in the way LIST does. A candidate might choose this option because it references stage files and a pattern, but its purpose is file transfer, not discovery.
- D. Incorrect.
Incorrect. DESCRIBE STAGE returns properties and configuration details of a stage object, such as its URL, storage integration, or credentials-related settings. It does not list the files currently stored under a path within the stage. The PATTERN clause is not part of DESCRIBE STAGE syntax.