Description
TheBSONEachRow format parses data as a sequence of Binary JSON (BSON) documents without any separator between them.
Each row is formatted as a single document and each column is formatted as a single BSON document field with the column name as a key.
Data types matching
For output it uses the following correspondence between ClickHouse types and BSON types:
For input it uses the following correspondence between BSON types and ClickHouse types:
Other BSON types are not supported. Additionally, it performs conversion between different integer types.
For example, it is possible to insert a BSON
int32 value into ClickHouse as UInt8.
Big integers and decimals such as Int128/UInt128/Int256/UInt256/Decimal128/Decimal256 can be parsed from a BSON Binary value with the \x00 binary subtype.
In this case, the format will validate that the size of the binary data equals the size of the expected value.
This format does not work properly on Big-Endian platforms.
Example usage
Inserting data
Using a BSON file with the following data, named asfootball.bson:
Reading data
Read data using theBSONEachRow format: