メインコンテンツまでスキップ
メインコンテンツまでスキップ

BSONEachRow

入力出力エイリアス

説明

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 または \x02 string (設定 output_format_bson_string_as_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 doubleFloat32/Float64
\x02 stringString/FixedString
\x03 documentMap/Named Tuple
\x04 arrayArray/Tuple
\x05 binary, \x00 binary subtypeString/FixedString/IPv6
\x05 binary, \x02 old binary subtypeString/FixedString
\x05 binary, \x03 old uuid subtypeUUID
\x05 binary, \x04 uuid subtypeUUID
\x07 ObjectIdString/FixedString
\x08 booleanBool
\x09 datetimeDateTime64
\x0A null valueNULL
\x0D JavaScript codeString/FixedString
\x0E symbolString/FixedString
\x10 int32Int32/UInt32/Decimal32/IPv4/Enum8/Enum16
\x12 int64Int64/UInt64/Decimal64/DateTime64

他の BSON 型はサポートされていません。さらに、異なる整数型間での変換が行われます。
例えば、BSON の int32 値を ClickHouse に UInt8 として挿入することが可能です。

Int128/UInt128/Int256/UInt256/Decimal128/Decimal256 のような大きな整数や小数は、\x00 バイナリサブタイプを持つ BSON バイナリ値から解析できます。
この場合、フォーマットはバイナリデータのサイズが期待される値のサイズと等しいことを検証します。

注記

このフォーマットはビッグエンディアンプラットフォームでは正常に動作しません。

使用例

フォーマット設定

設定説明デフォルト
output_format_bson_string_as_string文字列カラムに対してバイナリではなく BSON 文字列型を使用します。false
input_format_bson_skip_fields_with_unsupported_types_in_schema_inferenceフォーマット BSONEachRow のスキーマ推論中にサポートされていない型を持つカラムをスキップすることを許可します。false