Skip to content

Choose the right JSON input format ​

JSON is a family of input representations rather than a single row layout. json_each_row reads one object per row. Other registered formats handle arrays, columns or a whole document. Choose the format from the actual bytes and intended destination shape.

Load named rows ​

sql
CREATE TABLE customers(id UInt64, name String);

Send the following input as its own request:

sql
INSERT INTO customers FORMAT json_each_row
{"id":1,"name":"Ada"}
{"id":2,"name":"Grace"}

The keys map to destination columns. Declared types validate values. Unknown fields are errors unless the statement enables ignore_unknown_fields; enabling that option deliberately discards unmatched input rather than adding columns.

Keep input and later SQL separate ​

Everything after FORMAT json_each_row is input data, including semicolons. Run validation queries in a later request. Put any format SETTINGS before FORMAT, since settings after it would be interpreted as data.

If the source is an outer JSON array, use a matching whole-document format or convert it to row objects in the importer. For a document retained in one JSON column, preserve it as a document instead of assuming each nested field is automatically a table column.

See JSON input formats, json_each_row and JSON type.