SOL-C01 · Question #194
You are tasked with using the 'PARSE DOCUMENT' function in Snowflake to extract key information (name, address, phone number) from a large collection of scanned invoices stored as PDF files in an AWS
The correct answer is C. Create a custom UDF (User-Defined Function) that calls 'PARSE_DOCUMENT and then uses. Creating a custom UDF that calls PARSE_DOCUMENT and applies additional post-processing logic is the most effective approach for invoices with varying formats and quality. The UDF can normalize the raw JSON output from PARSE_DOCUMENT, apply validation rules, handle missing fields
Question
You are tasked with using the 'PARSE DOCUMENT' function in Snowflake to extract key information (name, address, phone number) from a large collection of scanned invoices stored as PDF files in an AWS S3 bucket. The invoices have varying formats and quality. Which of the following approaches would be MOST effective to structure the extracted data for analysis?
Options
- AUse `PARSE DOCUMENT with default settings and load the raw JSON output into a VARIANT
- BUse `PARSE DOCUMENT with a pre-defined JSON schema to enforce a rigid structure on the
- CCreate a custom UDF (User-Defined Function) that calls 'PARSE_DOCUMENT and then uses
- DEmploy a combination of 'PARSE DOCUMENT and Snowflake's external functions to integrate
- EDirectly load PDF files into a relational table's TEXT column and write SQL queries utilizing LIKE
How the community answered
(37 responses)- A3% (1)
- B8% (3)
- C84% (31)
- E5% (2)
Explanation
Creating a custom UDF that calls PARSE_DOCUMENT and applies additional post-processing logic is the most effective approach for invoices with varying formats and quality. The UDF can normalize the raw JSON output from PARSE_DOCUMENT, apply validation rules, handle missing fields gracefully, and map extracted values to a consistent structure (name, address, phone number) regardless of invoice layout differences. This encapsulates the transformation logic in a reusable, maintainable unit. Option A (loading raw JSON into VARIANT) defers all structuring to query time, making analysis harder. Option B (pre-defined rigid schema) fails for varying invoice formats. Option D (external functions) adds unnecessary complexity and latency for this use case. Option E (LIKE queries on raw text) is fragile and impractical for structured extraction from PDFs.
Topics
Community Discussion
No community discussion yet for this question.