From 94c6dc42ebaaaeccb7e9966f24cfaa4c91e030f2 Mon Sep 17 00:00:00 2001 From: avogar Date: Fri, 11 Nov 2022 13:17:48 +0000 Subject: [PATCH] Use better types --- docs/en/interfaces/formats.md | 5 ++--- src/Processors/Formats/Impl/BSONEachRowRowOutputFormat.cpp | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/en/interfaces/formats.md b/docs/en/interfaces/formats.md index 16913bbe307..153977674fb 100644 --- a/docs/en/interfaces/formats.md +++ b/docs/en/interfaces/formats.md @@ -1223,13 +1223,12 @@ For output it uses the following correspondence between ClickHouse types and BSO | [Bool](../sql-reference/data-types/boolean.md) | `\x08` boolean | | [Int8/UInt8](../sql-reference/data-types/int-uint.md) | `\x10` int32 | | [Int16UInt16](../sql-reference/data-types/int-uint.md) | `\x10` int32 | -| [Int32](../sql-reference/data-types/int-uint.md) | `\x10` int32 | -| [UInt32](../sql-reference/data-types/int-uint.md) | `\x12` int64 | +| [Int32/UInt32](../sql-reference/data-types/int-uint.md) | `\x10` int32 | | [Int64](../sql-reference/data-types/int-uint.md) | `\x12` int64 | | [UInt64](../sql-reference/data-types/int-uint.md) | `\x11` uint64 | | [Float32/Float64](../sql-reference/data-types/float.md) | `\x01` double | | [Date](../sql-reference/data-types/date.md)/[Date32](../sql-reference/data-types/date32.md) | `\x10` int32 | -| [DateTime](../sql-reference/data-types/datetime.md) | `\x12` int64 | +| [DateTime](../sql-reference/data-types/datetime.md) | `\x12` int32 | | [DateTime64](../sql-reference/data-types/datetime64.md) | `\x09` datetime | | [Decimal32](../sql-reference/data-types/decimal.md) | `\x10` int32 | | [Decimal64](../sql-reference/data-types/decimal.md) | `\x12` int64 | diff --git a/src/Processors/Formats/Impl/BSONEachRowRowOutputFormat.cpp b/src/Processors/Formats/Impl/BSONEachRowRowOutputFormat.cpp index f6ec47ccd82..d8b4e56a4bb 100644 --- a/src/Processors/Formats/Impl/BSONEachRowRowOutputFormat.cpp +++ b/src/Processors/Formats/Impl/BSONEachRowRowOutputFormat.cpp @@ -123,7 +123,9 @@ size_t BSONEachRowRowOutputFormat::countBSONFieldSize(const IColumn & column, co case TypeIndex::UInt16: [[fallthrough]]; case TypeIndex::Date: [[fallthrough]]; case TypeIndex::Date32: [[fallthrough]]; + case TypeIndex::DateTime: [[fallthrough]]; case TypeIndex::Decimal32: [[fallthrough]]; + case TypeIndex::UInt32: [[fallthrough]]; case TypeIndex::Int32: { return size + sizeof(Int32); @@ -137,10 +139,8 @@ size_t BSONEachRowRowOutputFormat::countBSONFieldSize(const IColumn & column, co } case TypeIndex::Float32: [[fallthrough]]; case TypeIndex::Float64: [[fallthrough]]; - case TypeIndex::UInt32: [[fallthrough]]; case TypeIndex::Int64: [[fallthrough]]; case TypeIndex::UInt64: [[fallthrough]]; - case TypeIndex::DateTime: [[fallthrough]]; case TypeIndex::Decimal64: [[fallthrough]]; case TypeIndex::DateTime64: { @@ -301,7 +301,7 @@ void BSONEachRowRowOutputFormat::serializeField(const IColumn & column, const Da case TypeIndex::DateTime: [[fallthrough]]; case TypeIndex::UInt32: { - writeBSONNumber(BSONType::INT64, column, row_num, name, out); + writeBSONNumber(BSONType::INT32, column, row_num, name, out); break; } case TypeIndex::Int64: