ChaomingZhangCN commented on code in PR #198:
URL: https://github.com/apache/paimon-cpp/pull/198#discussion_r3792061684
##########
src/paimon/common/types/data_type_json_parser.cpp:
##########
@@ -607,6 +615,34 @@ Result<std::shared_ptr<arrow::DataType>>
TokenParser::ParseTimestampLtzType() {
return ts_type;
}
+Result<std::shared_ptr<arrow::DataType>> TokenParser::ParseVectorType() {
+ PAIMON_RETURN_NOT_OK(NextToken(TokenType::BEGIN_SUBTYPE));
+ bool element_nullable = true;
+ AtomicTypeAttributes element_attributes;
+ PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<arrow::DataType> element_type,
+ ParseTypeWithNullability(&element_nullable,
&element_attributes));
+ if (element_attributes.is_blob || element_attributes.is_variant ||
+ !VectorType::IsValidElementType(element_type)) {
+ return Status::Invalid(
+ fmt::format("Invalid element type for vector: {}",
element_type->ToString()));
+ }
+ PAIMON_RETURN_NOT_OK(NextToken(TokenType::LIST_SEPARATOR));
+ PAIMON_RETURN_NOT_OK(NextToken(TokenType::LITERAL_INT));
+ const std::string& length_token = GetToken().value;
+ int64_t length = 0;
+ const auto [end, error] =
+ std::from_chars(length_token.data(), length_token.data() +
length_token.size(), length);
+ if (error != std::errc() || end != length_token.data() +
length_token.size() || length < 1 ||
+ length > std::numeric_limits<int32_t>::max()) {
+ return Status::Invalid(
+ fmt::format("Vector length must be between 1 and {} (both
inclusive), but was {}",
+ std::numeric_limits<int32_t>::max(), length_token));
+ }
Review Comment:
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]