yiguolei commented on code in PR #58905:
URL: https://github.com/apache/doris/pull/58905#discussion_r2609382391
##########
be/src/olap/delete_handler.cpp:
##########
@@ -43,6 +51,298 @@ using ::google::protobuf::RepeatedPtrField;
namespace doris {
+template <PrimitiveType PType>
+typename PrimitiveTypeTraits<PType>::CppType convert(const
vectorized::DataTypePtr& data_type,
+ const std::string& str,
+ vectorized::Arena& arena)
{
+ typename PrimitiveTypeTraits<PType>::CppType res;
+ if constexpr (PType == TYPE_TINYINT || PType == TYPE_SMALLINT || PType ==
TYPE_INT ||
+ PType == TYPE_BIGINT || PType == TYPE_LARGEINT) {
+ vectorized::CastParameters parameters;
+ if (!vectorized::CastToInt::from_string({str.data(), str.size()}, res,
parameters)) {
+ throw Exception(Status::Error<ErrorCode::INVALID_ARGUMENT>(
+ "invalid {} string. str={}",
type_to_string(data_type->get_primitive_type()),
+ str));
+ }
+ return res;
+ }
+ if constexpr (PType == TYPE_FLOAT || PType == TYPE_DOUBLE) {
+ vectorized::CastParameters parameters;
+ if (!vectorized::CastToFloat::from_string({str.data(), str.size()},
res, parameters)) {
+ throw Exception(Status::Error<ErrorCode::INVALID_ARGUMENT>(
+ "invalid {} string. str={}",
type_to_string(data_type->get_primitive_type()),
+ str));
+ }
+ return res;
+ }
+ if constexpr (PType == TYPE_DATE) {
+ vectorized::CastParameters parameters;
+ if (!vectorized::CastToDateOrDatetime::from_string<false>({str.data(),
str.size()}, res,
+ nullptr,
parameters)) {
+ throw Exception(Status::Error<ErrorCode::INVALID_ARGUMENT>(
+ "invalid {} string. str={}",
type_to_string(data_type->get_primitive_type()),
+ str));
+ }
+ return res;
+ }
+ if constexpr (PType == TYPE_DATETIME) {
+ vectorized::CastParameters parameters;
+ if (!vectorized::CastToDateOrDatetime::from_string<true>({str.data(),
str.size()}, res,
+ nullptr,
parameters)) {
+ throw Exception(Status::Error<ErrorCode::INVALID_ARGUMENT>(
+ "invalid {} string. str={}",
type_to_string(data_type->get_primitive_type()),
+ str));
+ }
+ return res;
+ }
+ if constexpr (PType == TYPE_DATEV2) {
+ vectorized::CastParameters parameters;
+ if (!vectorized::CastToDateV2::from_string({str.data(), str.size()},
res, nullptr,
+ parameters)) {
+ throw Exception(Status::Error<ErrorCode::INVALID_ARGUMENT>(
Review Comment:
这里不要throw exception,这个delete handler 在compaction
这类的存储过程中也使用,而这些代码一般都不讲究异常,所以我们还是得返回status
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]