SnowPro Associate: Platform Question 288
Single answer3.4 Explain how to work with unstructured data.A media analytics team stores product images and PDF manuals in an internal stage in Snowflake. They need a solution that lets analysts query metadata about these files with SQL and generate secure, time-limited links so downstream users can access specific files without making the stage public. Which approach should the team use?
- A
Create a directory table on the stage, query file metadata from the directory table, and use GET_PRESIGNED_URL to generate temporary access links.
- B
Load the image and PDF files into a VARIANT column using COPY INTO, then query the VARIANT metadata and use SECURE VIEW URLs for file download.
- C
Create an external table on the internal stage and use it to expose file metadata, then use LIST @stage to generate permanent download links.
- D
Use the INFER_SCHEMA function on the stage to return file metadata for the images and PDFs, then use BUILD_SCOPED_FILE_URL for anonymous public access.
Show answer and explanation
Correct answer: A
Explanation
The best answer is to use a directory table on the stage together with GET_PRESIGNED_URL. In Snowflake, unstructured data files can be stored in stages, and directory tables provide SQL-accessible metadata about staged files. This is a common pattern when teams need to inventory or search files without loading them into database tables. For controlled access, Snowflake provides functions such as GET_PRESIGNED_URL to create secure, time-limited links to staged files. This satisfies both requirements in the scenario: querying file metadata and securely sharing file access. By contrast, loading images and PDFs into VARIANT is not the normal model for unstructured data management, external tables are not the right fit for internal stages in this scenario, and INFER_SCHEMA applies to schema discovery for supported structured or semi-structured formats rather than generic unstructured files. These behaviors align with Snowflake documentation on unstructured data, directory tables, stages, and file URL generation best practices.
- A. Correct.
Correct. For unstructured data in Snowflake, a directory table can be enabled on a stage to expose file-level metadata such as relative path, size, and last modified timestamp through SQL. To provide secure, time-limited access to files in a stage, Snowflake supports presigned URLs via the GET_PRESIGNED_URL function. This matches the requirement to query metadata and share temporary access without making the stage public.
- B. Incorrect.
Incorrect. COPY INTO is used to load structured or semi-structured data into tables, but it is not the standard approach for storing and managing unstructured files like images and PDFs for direct staged access. Also, SECURE VIEW does not generate file download URLs; secure views protect query logic and data exposure, not staged file delivery.
- C. Incorrect.
Incorrect. External tables are designed for files in external stages, not internal stages, and are primarily used for querying structured or semi-structured data files rather than managing unstructured file access patterns. In addition, LIST returns file listings but does not generate permanent or secure download links.
- D. Incorrect.
Incorrect. INFER_SCHEMA is used to detect schema from semi-structured or structured files such as JSON, Avro, Parquet, ORC, and CSV, not to manage metadata for unstructured image and PDF files. BUILD_SCOPED_FILE_URL creates a scoped URL for staged files, but the statement that it provides anonymous public access is wrong; scoped access is controlled and not equivalent to public anonymous access.