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

BSONEachRow

InputOutputAlias

説明

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 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 などの大きな整数と小数は、BSON バイナリ値から \x00 バイナリサブタイプで解析できます。 この場合、フォーマットはバイナリデータのサイズが期待される値のサイズに等しいことを検証します。

注記

このフォーマットはビッグエンディアンプラットフォームでは正しく機能しません。

使用例

フォーマット設定

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