COPY FROM required. Access the data either through a location object (recommended, and the way to read from sources other than Amazon S3) or through a direct Amazon S3 URL with credentials.
READ_JSON has two modes:
- Schema inference (default) — the column names and types are inferred from the data. Nested objects become STRUCT columns and arrays become
ARRAYcolumns. PARSE_AS_JSON => TRUE— no inference; every JSON document becomes one row with a single column namedjsonof type JSON. Use this for schemaless, polymorphic, or deeply irregular data, and as the escape hatch whenever schema inference fails.
Syntax
AWS_ROLE_ARN, set the optional AWS_ROLE_EXTERNAL_ID to add a customer-controlled condition to your role’s trust policy.
For role-based AWS access you can additionally set an external ID. An external ID is a value you choose and control that AWS checks when Firebolt assumes your role, adding a second condition on top of your account’s unique IAM principal. Configuring one is a recommended best practice. See IAM roles.
Parameters
- When using static credentials, the
URLcan be passed as either the first positional parameter or a named parameter, and credentials are not required for accessing public buckets.
Accepted file contents
Each file may contain:- Newline-delimited JSON (NDJSON / JSON Lines) — one document per line. This is the recommended format.
- A single JSON document, including pretty-printed documents spanning multiple lines, which yields exactly one row.
- One top-level JSON array of objects (
[{...}, {...}]) — every array element becomes a row.
Schema inference
The schema is inferred from the most recently modified file matching the URL or pattern. That file is read in full, and every document in it contributes to the schema:- The column set is the union of all keys across the documents. A key missing from a document yields
NULLin that row. - Nested objects become
STRUCTcolumns (recursively); arrays becomeARRAYcolumns, including arrays of structs. - Other matching files do not influence the schema. When they are read, their unknown keys are ignored and missing keys yield
NULL. These files are decoded tolerantly, matching JSON external tables: some non-conformant constructs (for example unquoted boolean words or trailing commas in arrays) are accepted rather than rejected.
All inferred columns are nullable. Integers and fractional numbers in the same key unify to
DOUBLE PRECISION. A JSON null always becomes SQL NULL.
When inference fails, use
PARSE_AS_JSON => TRUE. Schema inference fails with an actionable error when a key has irreconcilable types across documents (for example a number in one document and a string in another), when a document contains duplicate keys, or when the schema would exceed 500 keys (nested keys included — a guard against map-like documents with unique keys exploding into thousands of columns). In all of these cases, PARSE_AS_JSON => TRUE reads the same files without restrictions, returning each document as a single JSON value.Return Type
In the default mode, the result is a table whose columns follow the inferred schema. WithPARSE_AS_JSON => TRUE, the result is a table with a single nullable column json of type JSON, one row per document; every document is validated as well-formed JSON.
Like the other read functions, READ_JSON exposes the $source_file_name and $source_file_timestamp pseudo columns identifying the file each row came from.
Examples
Example Read events with an inferred schema, including nested structs, and access struct fields:Related
- Load semi-structured JSON data — how
READ_JSONrelates to JSON external tables and loading JSON into managed tables.