#pragma once #include namespace DB { /** Binary encoding for ClickHouse data types: |---------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ClickHouse data type | Binary encoding | |---------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Nothing | 0x00 | | UInt8 | 0x01 | | UInt16 | 0x02 | | UInt32 | 0x03 | | UInt64 | 0x04 | | UInt128 | 0x05 | | UInt256 | 0x06 | | Int8 | 0x07 | | Int16 | 0x08 | | Int32 | 0x09 | | Int64 | 0x0A | | Int128 | 0x0B | | Int256 | 0x0C | | Float32 | 0x0D | | Float64 | 0x0E | | Date | 0x0F | | Date32 | 0x10 | | DateTime | 0x11 | | DateTime(time_zone) | 0x12 | | DateTime64(P) | 0x13 | | DateTime64(P, time_zone) | 0x14 | | String | 0x15 | | FixedString(N) | 0x16 | | Enum8 | 0x17... | | Enum16 | 0x18...> | | Decimal32(P, S) | 0x19 | | Decimal64(P, S) | 0x1A | | Decimal128(P, S) | 0x1B | | Decimal256(P, S) | 0x1C | | UUID | 0x1D | | Array(T) | 0x1E | | Tuple(T1, ..., TN) | 0x1F... | | Tuple(name1 T1, ..., nameN TN) | 0x20... | | Set| 0x21 | | Interval | 0x22 | | Nullable(T) | 0x23 | | Function | 0x24... | | AggregateFunction(function_name(param_1, ..., param_N), arg_T1, ..., arg_TN) | 0x25...... | | LowCardinality(T) | 0x26 | | Map(K, V) | 0x27 | | IPv4 | 0x28 | | IPv6 | 0x29 | | Variant(T1, ..., TN) | 0x2A... | | Dynamic(max_types=N) | 0x2B | | Custom type (Ring, Polygon, etc) | 0x2C | | Bool | 0x2D | | SimpleAggregateFunction(function_name(param_1, ..., param_N), arg_T1, ..., arg_TN) | 0x2E...... | | Nested(name1 T1, ..., nameN TN) | 0x2F... | | JSON(max_dynamic_paths=N, max_dynamic_types=M, path Type, SKIP skip_path, SKIP REGEXP skip_path_regexp) | 0x30......... | |---------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Interval kind binary encoding: |---------------|-----------------| | Interval kind | Binary encoding | |---------------|-----------------| | Nanosecond | 0x00 | | Microsecond | 0x01 | | Millisecond | 0x02 | | Second | 0x03 | | Minute | 0x04 | | Hour | 0x05 | | Day | 0x06 | | Week | 0x07 | | Month | 0x08 | | Quarter | 0x09 | | Year | 0x1A | |---------------|-----------------| Aggregate function parameter binary encoding (binary encoding of a Field, see src/Common/FieldBinaryEncoding.h): |------------------------|------------------------------------------------------------------------------------------------------------------------------| | Parameter type | Binary encoding | |------------------------|------------------------------------------------------------------------------------------------------------------------------| | Null | 0x00 | | UInt64 | 0x01 | | Int64 | 0x02 | | UInt128 | 0x03 | | Int128 | 0x04 | | UInt128 | 0x05 | | Int128 | 0x06 | | Float64 | 0x07 | | Decimal32 | 0x08 | | Decimal64 | 0x09 | | Decimal128 | 0x0A | | Decimal256 | 0x0B | | String | 0x0C | | Array | 0x0D... | | Tuple | 0x0E... | | Map | 0x0F... | | IPv4 | 0x10 | | IPv6 | 0x11 | | UUID | 0x12 | | Bool | 0x13 | | Object | 0x14... | | AggregateFunctionState | 0x15 | | Negative infinity | 0xFE | | Positive infinity | 0xFF | |------------------------|------------------------------------------------------------------------------------------------------------------------------| */ String encodeDataType(const DataTypePtr & type); void encodeDataType(const DataTypePtr & type, WriteBuffer & buf); DataTypePtr decodeDataType(const String & data); DataTypePtr decodeDataType(ReadBuffer & buf); }