BSONEachRow
Input | Output | Alias |
---|---|---|
✔ | ✔ |
説明
BSONEachRow
フォーマットは、区切り文字なしにバイナリ JSON (BSON) 文書のシーケンスとしてデータを解析します。
各行は単一の文書としてフォーマットされ、各カラムはカラム名をキーとする単一の BSON 文書フィールドとしてフォーマットされます。
データ型の対応
出力には、ClickHouse 型と BSON 型の間の次の対応を使用します。
ClickHouse 型 | BSON 型 |
---|---|
Bool | \x08 boolean |
Int8/UInt8/Enum8 | \x10 int32 |
Int16/UInt16/Enum16 | \x10 int32 |
Int32 | \x10 int32 |
UInt32 | \x12 int64 |
Int64/UInt64 | \x12 int64 |
Float32/Float64 | \x01 double |
Date/Date32 | \x10 int32 |
DateTime | \x12 int64 |
DateTime64 | \x09 datetime |
Decimal32 | \x10 int32 |
Decimal64 | \x12 int64 |
Decimal128 | \x05 binary, \x00 binary subtype, size = 16 |
Decimal256 | \x05 binary, \x00 binary subtype, size = 32 |
Int128/UInt128 | \x05 binary, \x00 binary subtype, size = 16 |
Int256/UInt256 | \x05 binary, \x00 binary subtype, size = 32 |
String/FixedString | \x05 binary, \x00 binary subtype または、設定 output_format_bson_string_as_string が有効な場合は \x02 string |
UUID | \x05 binary, \x04 uuid subtype, size = 16 |
Array | \x04 array |
Tuple | \x04 array |
Named Tuple | \x03 document |
Map | \x03 document |
IPv4 | \x10 int32 |
IPv6 | \x05 binary, \x00 binary subtype |
入力には、BSON 型と ClickHouse 型の間の次の対応を使用します。
BSON 型 | ClickHouse 型 |
---|---|
\x01 double | Float32/Float64 |
\x02 string | String/FixedString |
\x03 document | Map/Named Tuple |
\x04 array | Array/Tuple |
\x05 binary, \x00 binary subtype | String/FixedString/IPv6 |
\x05 binary, \x02 old binary subtype | String/FixedString |
\x05 binary, \x03 old uuid subtype | UUID |
\x05 binary, \x04 uuid subtype | UUID |
\x07 ObjectId | String/FixedString |
\x08 boolean | Bool |
\x09 datetime | DateTime64 |
\x0A null value | NULL |
\x0D JavaScript code | String/FixedString |
\x0E symbol | String/FixedString |
\x10 int32 | Int32/UInt32/Decimal32/IPv4/Enum8/Enum16 |
\x12 int64 | Int64/UInt64/Decimal64/DateTime64 |
他の BSON 型はサポートされていません。また、異なる整数型の間での変換も行います。
例えば、BSON int32
値を ClickHouse に UInt8
として挿入することが可能です。
Int128
/UInt128
/Int256
/UInt256
/Decimal128
/Decimal256
などの大きな整数と小数は、BSON バイナリ値から \x00
バイナリサブタイプで解析できます。
この場合、フォーマットはバイナリデータのサイズが期待される値のサイズに等しいことを検証します。
注記
このフォーマットはビッグエンディアンプラットフォームでは正しく機能しません。
使用例
フォーマット設定
設定 | 説明 | デフォルト |
---|---|---|
output_format_bson_string_as_string | 文字列カラムのためにバイナリではなく BSON 文字列型を使用します。 | false |
input_format_bson_skip_fields_with_unsupported_types_in_schema_inference | フォーマット BSONEachRow のスキーマ推論中にサポートされていない型のカラムをスキップできるようにします。 | false |