Fixes addressing review comments

This commit is contained in:
Mikhail Koviazin 2024-03-06 14:35:48 +02:00
parent 11371e886c
commit 490efd2efa
No known key found for this signature in database
GPG Key ID: 0EEAA1BF0787792F

View File

@ -53,6 +53,7 @@ namespace ErrorCodes
{
extern const int NO_COLUMNS_SERIALIZED_TO_PROTOBUF_FIELDS;
extern const int MULTIPLE_COLUMNS_SERIALIZED_TO_SAME_PROTOBUF_FIELD;
extern const int NO_COLUMN_SERIALIZED_TO_REQUIRED_PROTOBUF_FIELD;
extern const int DATA_TYPE_INCOMPATIBLE_WITH_PROTOBUF_FIELD;
extern const int PROTOBUF_FIELD_NOT_REPEATED;
extern const int PROTOBUF_BAD_CAST;
@ -167,8 +168,6 @@ namespace
default:
return false;
}
if (field_descriptor.options().has_packed())
return field_descriptor.options().packed();
return field_descriptor.is_packed();
}
@ -3444,6 +3443,20 @@ namespace
}
}
/// Check that we've found matching columns for all the required fields.
if (reader_or_writer.writer)
{
for (int i : collections::range(message_descriptor.field_count()))
{
const auto & field_descriptor = *message_descriptor.field(i);
if (field_descriptor.is_required() && !field_descriptors_in_use.count(&field_descriptor))
throw Exception(
ErrorCodes::NO_COLUMN_SERIALIZED_TO_REQUIRED_PROTOBUF_FIELD,
"Field {} is required to be set",
quoteString(field_descriptor.full_name()));
}
}
if (field_descs.empty())
return nullptr;