Skip to content

json_columns ​

Description ​

One JSON object mapping each column name to an array of values. Column arrays must have compatible row counts. json_columns_sql_defaults selects SQL defaults for omitted fields.

Input and output. Select it with FORMAT json_columns. Names ignore ASCII case; use the snake_case name shown here.

Each object key names a column, and its value is an array containing that column's rows. Corresponding positions across the arrays form one SQL row.

Column lengths must agree. Omitted target columns follow json_columns_sql_defaults and their declarations. Use json_each_row when the source provides objects per row rather than arrays per column.

text
SELECT expressions FORMAT json_columns;
INSERT INTO table [(columns)] [SETTINGS ...] FORMAT json_columns
<data>

Example usage ​

sql
SELECT CAST(7 AS Int64) AS id, 'Ada' AS name FORMAT json_columns;
text
{
    "id": [7],
    "name": ["Ada"]
}

Format settings ​

Use a statement SETTINGS clause; these options are not persisted by SET.

Setting Type Default Meaning
ignore_unknown_fields Bool 0 Skip input keys and header names that match no target column instead of failing.
json_columns_sql_defaults Bool 1 Evaluate SQL DEFAULT expressions for omitted input columns; off supplies only their native type defaults.
snappy_mode String basic Read Snappy client files as basic (Hadoop blocks) or framed (standard streaming format).