Document Processing
This domain covers extracting text and structured data from documents to feed Gen AI pipelines, using Snowflake's Cortex document-processing functions — the SQL-callable successor to the retired Document AI model-build UI. Expect questions on choosing OCR versus LAYOUT mode, reading source files from stages correctly, chunking extracted text, building the full document-to-RAG pipeline in the right order, and pulling structured fields out of parsed documents.
Parsing Documents: PARSE_DOCUMENT / AI_PARSE_DOCUMENT
PARSE_DOCUMENT (also available as AI_PARSE_DOCUMENT) extracts text from documents such as PDFs and images, combining OCR (optical character recognition, for scanned or image-based content) with layout awareness (understanding structural elements like headings, tables, and reading order).
OCR vs. LAYOUT Mode
| Mode | Behavior | Best for |
|---|---|---|
| OCR mode | Returns plain extracted text, without preserving structure | Simple text extraction where reading order and structure don't matter much |
| LAYOUT mode | Preserves structure — tables, headings, reading order — in the output | Documents where structure matters for downstream understanding, and for producing higher-quality chunks for embedding |
Worked scenario: "We need to extract line items from scanned invoices where the table structure (columns, rows) must be preserved for accurate downstream field extraction." That structural requirement points to LAYOUT mode — OCR mode alone would return a flattened block of text that loses which numbers belonged to which table cell. Contrast with a scenario that just needs the raw text of a plain letter dumped into a column for keyword search — OCR mode is sufficient and cheaper to reason about.
Choosing a Mode
Picking OCR mode when the downstream step needs table structure is not just a lower-quality choice — it is often unrecoverable: once text has been flattened, there is no getting the column/row boundaries back without re-parsing the original file in LAYOUT mode.
Reading Source Files: Stages and Directory Tables
Documents to be parsed live on stages — internal (Snowflake-managed) or external (a customer-owned cloud storage location Snowflake has been granted access to). To reference and iterate over the individual files on a stage in SQL, you typically use a directory table — metadata about the files on a stage (file name, size, last-modified, and a way to reference each file) that lets you run PARSE_DOCUMENT across a whole set of files programmatically rather than one hardcoded path at a time.
Unlock with a paid plan
5 more sections (about 840 words) continue below. Every paid plan unlocks all GES-C02 study guides, the full question bank and mock exams, from $4.97/month.