diff --git a/src/Formats/ProtobufSerializer.cpp b/src/Formats/ProtobufSerializer.cpp index 87cd657e5b7..4679b77ef61 100644 --- a/src/Formats/ProtobufSerializer.cpp +++ b/src/Formats/ProtobufSerializer.cpp @@ -102,6 +102,29 @@ namespace } }; + bool isGoogleWrapperMessage(const MessageDescriptor & message_descriptor) + { + auto message_type = message_descriptor.well_known_type(); + return (message_type >= google::protobuf::Descriptor::WELLKNOWNTYPE_DOUBLEVALUE) + && (message_type <= google::protobuf::Descriptor::WELLKNOWNTYPE_BOOLVALUE); + } + + bool isGoogleWrapperField(const FieldDescriptor & field_descriptor) + { + + const auto * message_descriptor = field_descriptor.message_type(); + if (message_descriptor == nullptr) + { + return false; + } + return isGoogleWrapperMessage(*message_descriptor); + } + + std::string_view googleWrapperColumnName(const FieldDescriptor & field_descriptor) + { + assert(isGoogleWrapperField(field_descriptor)); + return field_descriptor.message_type()->field(0)->name(); + } // Should we omit null values (zero for numbers / empty string for strings) while storing them. bool shouldSkipZeroOrEmpty(const FieldDescriptor & field_descriptor) @@ -110,6 +133,8 @@ namespace return false; if (field_descriptor.containing_type()->options().map_entry()) return false; + if (isGoogleWrapperField(field_descriptor)) + return false; return field_descriptor.message_type() || (field_descriptor.file()->syntax() == google::protobuf::FileDescriptor::SYNTAX_PROTO3); } @@ -143,30 +168,6 @@ namespace return field_descriptor.file()->syntax() == google::protobuf::FileDescriptor::SYNTAX_PROTO3; } - bool isGoogleWrapperMessage(const MessageDescriptor & message_descriptor) - { - auto message_type = message_descriptor.well_known_type(); - return (message_type >= google::protobuf::Descriptor::WELLKNOWNTYPE_DOUBLEVALUE) - && (message_type <= google::protobuf::Descriptor::WELLKNOWNTYPE_BOOLVALUE); - } - - bool isGoogleWrapperField(const FieldDescriptor & field_descriptor) - { - - const auto * message_descriptor = field_descriptor.message_type(); - if (message_descriptor == nullptr) - { - return false; - } - return isGoogleWrapperMessage(*message_descriptor); - } - - std::string_view googleWrapperColumnName(const FieldDescriptor & field_descriptor) - { - assert(isGoogleWrapperField(field_descriptor)); - return field_descriptor.message_type()->field(0)->name(); - } - WriteBuffer & writeIndent(WriteBuffer & out, size_t size) { return out << String(size * 4, ' '); }