FL_FILTER_PAGES

functionnot supportedData loading & unloading

docs.snowflake.com ↗

File functions

Selects pages of a multi-page document for processing by Cortex AI Functions for document intelligence. Use this function as the file argument of AI_EXTRACT or AI_PARSE_DOCUMENT when you only need part of a document. The function processes the pages you select instead of the whole document.

Syntax

FL_FILTER_PAGES( <file> , <pages> )

Parameters

NameRequiredDescription
filerequiredA FILE value that refers to a multi-page document.
pagesrequiredAn ARRAY of objects, each of which selects a range of pages. The array must contain at least one object and at most 4,096. Each object can contain a start field, an end field, or both. Both fields are signed integers and specify the first (inclusive) and last (exclusive) page of the range. Page indexes start at 0. For example, {'start': 0, 'end': 3} selects the first three pages. Omit either field to leave that end of the range open. An omitted start means the first page of the document, and an omitted end means the last page. Use a negative value to count backward from the end of the document: {'start': -3} selects the last three pages, and {'end': -1} selects everything except the last page.

Returns

A FILE value that carries the page selection. Pass it directly as the file argument of AI_EXTRACT and AI_PARSE_DOCUMENT functions, which then process only the selected pages.

Usage notes

Error conditions

Errors are reported per row: the offending row fails and the rest of the query continues. Condition | Result The array is empty or isn’t an array. | Rejected. A selection, when you supply one, needs at least one object. The array contains more than 4,096 objects. | Rejected. The whole call fails, so a selection is never silently narrowed to the first 4,096 ranges. An item isn’t an object, or contains a field other than start and end. | Rejected. start or end is present but isn’t an integer. This includes NULL, a decimal value, a string, and a value outside the range of a signed 32-bit integer. | Rejected. Omitting a field is valid; setting it to NULL isn’t. Both fields are present, both are non-negative or both are negative, and end is less than or equal to start. | Rejected. Ranges such as {'start': 3, 'end': 3}, {'start': 5, 'end': 2}, and {'start': -1, 'end': -2} are empty for every document. end is 0, whatever start is. | Rejected. Ranges such as {'end': 0} and {'start': -3, 'end': 0} are empty for every document. The selection is valid but resolves to no pages for a particular document. | AI_PARSE_DOCUMENT fails the row. AI_EXTRACT returns an empty result for the row. Any other range, including one that mixes a negative value with a non-negative one, is accepted and resolved against the actual number of pages in each document.

See also