Skip to content
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

Merged
merged 5 commits into from
Apr 20, 2023

Conversation

Avogar
Copy link
Member

@Avogar Avogar commented Apr 6, 2023

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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' and Bad cast from type DB::ColumnVector<StrongTypedef<unsigned int, DB::IPv4Tag>> to DB::ColumnVector<unsigned int>' in Protobuf format.

@@ -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());
Copy link
Member Author

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.

@vitlibar vitlibar self-assigned this Apr 6, 2023
}
};

class ProtobufSerializerIPv4 : public ProtobufSerializerNumber<IPv4>
Copy link
Member

@vitlibar vitlibar Apr 7, 2023

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?

Copy link
Member Author

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

Copy link
Member

@vitlibar vitlibar Apr 12, 2023

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.

Copy link
Member Author

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.

@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-bugfix Pull request with bugfix, not backported by default label Apr 19, 2023
@Avogar Avogar requested a review from vitlibar April 19, 2023 11:29
@Avogar Avogar merged commit 3fc9c31 into ClickHouse:master Apr 20, 2023
141 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix Pull request with bugfix, not backported by default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants