-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix logical error with IPv4 in Protobuf, add support for Date32 #48486
Conversation
@@ -3508,7 +3513,7 @@ namespace | |||
} | |||
|
|||
default: | |||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Unknown data type: {}", data_type->getName()); | |||
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Type {} is not supported in Protobuf format", data_type->getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not throw LOGICAL_ERROR
here. We can add new types in future and forget to support it in Protobuf format. It's ok to thow just ILLEGAL_COLUMN
.
} | ||
}; | ||
|
||
class ProtobufSerializerIPv4 : public ProtobufSerializerNumber<IPv4> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we write : public ProtobufSerializerNumber<UInt32>
here for consistency with ProtobufSerializerDate
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot, because otherwise we will get logical error Bad cast from type DB::ColumnVector<StrongTypedef<unsigned int, DB::IPv4Tag>> to DB::ColumnVector<unsigned int>'
. IPv4
type is not the same as UInt32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I see. DataTypeDate
is derived from DataTypeNumberBase<UInt16>
however for unknown reason DataTypeIPv4
is not derived from DataTypeNumberBase<UInt32>
.
Probably if DataTypeIPv4
was derived from DataTypeNumberBase<UInt32>
with ColumnType = ColumnVector<UInt32>
, that would make things easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to change it to DataTypeNumberBase<UInt32>
with ColumnType = ColumnVector<UInt32>
, but seems like it won't work as in some places we need to distinguish between ColumnVector<UInt32>
and ColumnIPv4
(for example for proper CAST I guess) and that's the reason it's implemented as separate DataType. Let's keep it as is.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix possible logical errors
Logical error: 'Unknown data type: Date32'
andBad cast from type DB::ColumnVector<StrongTypedef<unsigned int, DB::IPv4Tag>> to DB::ColumnVector<unsigned int>'
in Protobuf format.