Skip to main content
Experimental feature Advice on use of experimental features Constructs a temporary FILE value from a STRUCT expression, such as named_struct(...) or a STRUCT column. This function does not access storage or infer metadata.

Syntax

Parameters

struct_expr: a STRUCT expression that describes the file. The following fields are accepted:

Return value

Returns a FILE value. If struct_expr is NULL, returns NULL.

Usage notes

  • Field names are case-insensitive and can appear in any order. Unknown or duplicate names cause an analysis error.
  • Missing fields and explicit NULL values become NULL. No defaults are filled in, including for offset and size.
  • For each non-NULL STRUCT, exactly one of uri and inline must be non-NULL. Missing fields count as NULL.
  • Integer inputs are widened to BIGINT. Untyped NULL is accepted for every field. Other input types require an explicit CAST.
  • For URI references, offset and size can be NULL; non-NULL values must be greater than or equal to zero. For inline content, both fields must be NULL. A row that violates these rules or the uri/inline rule causes the query to fail. To return NULL for such rows instead, use try_to_file.
  • URI syntax, MIME types, checksums, and the referenced byte range are not validated.
  • inline contains raw bytes. Empty strings and empty binary values count as non-NULL and are preserved.
When ai_complete or ai_embed consumes a FILE with a missing or empty content_type, the AI function attempts to infer it. See FILE input support.

Examples

Example 1: Construct a file reference

Example 2: Construct inline content

Example 3: NULL argument

keyword

TO_FILE, FILE