与 JSONColumns 格式的不同之处在于,它还包含一些元数据和统计信息 (类似于 JSON 格式) 。
JSONColumnsWithMetadata 格式会先将所有数据缓冲在内存中,再以单个块的形式输出,因此可能会导致较高的内存占用。
示例:
{
"meta":
[
{
"name": "num",
"type": "Int32"
},
{
"name": "str",
"type": "String"
},
{
"name": "arr",
"type": "Array(UInt8)"
}
],
"data":
{
"num": [42, 43, 44],
"str": ["hello", "hello", "hello"],
"arr": [[0,1], [0,1,2], [0,1,2,3]]
},
"rows": 3,
"rows_before_limit_at_least": 3,
"statistics":
{
"elapsed": 0.000272376,
"rows_read": 3,
"bytes_read": 24
}
}
对于 JSONColumnsWithMetadata 输入格式,如果将设置 input_format_json_validate_types_from_metadata 设为 1,
则会比较输入数据元数据中的类型与表中对应列的类型。