zclllyybb commented on code in PR #34258:
URL: https://github.com/apache/doris/pull/34258#discussion_r1586450693


##########
be/src/vec/functions/function_string.h:
##########
@@ -356,6 +357,174 @@ class FunctionStrcmp : public IFunction {
     }
 };
 
+class FunctionAutoPartitionName : public IFunction {
+public:
+    static constexpr auto name = "auto_partition_name";
+    static FunctionPtr create() { return 
std::make_shared<FunctionAutoPartitionName>(); }
+    String get_name() const override { return name; }
+    size_t get_number_of_arguments() const override { return 0; }
+    bool is_variadic() const override { return true; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
+        return std::make_shared<DataTypeString>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) const override 
{
+        DCHECK_GE(arguments.size(), 2);
+
+        int argument_size = arguments.size();
+        std::vector<const ColumnString::Chars*> chars_list(argument_size);
+
+        for (int i = 0; i < argument_size; ++i) {
+            const auto& [col, is_const] =
+                    
unpack_if_const(block.get_by_position(arguments[i]).column);
+
+            const auto* col_str = assert_cast<const ColumnString*>(col.get());
+            chars_list[i] = &col_str->get_chars();
+        }
+
+        auto res = ColumnString::create();
+        auto& res_data = res->get_chars();
+        auto& res_offset = res->get_offsets();
+        res_offset.resize(input_rows_count);
+
+        auto compare_str = [&](const char* str1, const char* str2, size_t n) {
+            for (int i = 0; i < n; i++) {
+                if (str1[i] != str2[i]) {
+                    return 0;
+                }
+            }
+            return 1;
+        };
+        if (compare_str(chars_list[0]->raw_data(), "list", 4)) {
+            std::string res_p = "p";
+            for (int i = 0; i < input_rows_count; i++) {
+                int curr_size = 0;
+                for (int j = 1; j < argument_size; j++) {
+                    const std::string 
string_to_unicode(chars_list[j]->raw_data(),
+                                                        chars_list[j]->size());
+                    auto unicode_to_string = 
string_to_u16string(string_to_unicode);
+                    res_p += StringToUnicode(unicode_to_string) +
+                             std::to_string(unicode_to_string.size());
+                }
+                int len = res_p.size();
+                res_data.resize(len + curr_size);
+                std::memcpy(&res_data[res_offset[i - 1]], res_p.c_str(), len);
+                res_offset[i] = res_offset[i - 1] + len;
+            }
+
+            block.get_by_position(result).column = std::move(res);
+            return Status::OK();
+        } else if (compare_str(chars_list[0]->raw_data(), "range", 5)) {
+            if (argument_size != 3) {
+                return Status::Error<ErrorCode::INVALID_ARGUMENT>(
+                        "partition type is range, the argument of size must be 
3");
+            }
+            const auto& [col_partition_type, is_const_col_partition_type] =
+                    
unpack_if_const(block.get_by_position(arguments[1]).column);
+
+            const auto* col_str_partition_type_str =
+                    assert_cast<const ColumnString*>(col_partition_type.get());
+
+            std::string to_split_s(chars_list[2]->raw_data(), 
chars_list[2]->size());
+            std::vector<std::string> str_v;
+            if (to_split_s.size() == input_rows_count * 19) {
+                for (int i = 0; i < to_split_s.size(); i += 19) {
+                    auto vec_res = split(to_split_s.substr(i, 10), "-");
+                    for (const auto& s : vec_res) {
+                        str_v.emplace_back(s);
+                    }
+                }
+            } else {
+                for (int i = 0; i < to_split_s.size(); i += 10) {
+                    auto vec_res = split(to_split_s.substr(i, 10), "-");
+                    for (const auto& s : vec_res) {
+                        str_v.emplace_back(s);
+                    }
+                }
+            }
+            res_data.resize(15 * input_rows_count);
+            for (int i = 0; i < input_rows_count; i++) {
+                int curr_len = 1;
+
+                res_data[res_offset[i - 1]] = 'p';
+                if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "day", 3)) {
+                    for (int j = i * 3; j < i * 3 + 3; j++) {
+                        std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[j].c_str(),
+                                    str_v[j].size());
+                        curr_len += str_v[j].size();
+                    }
+                } else if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "month",
+                                       5)) {
+                    for (int j = i * 3; j < i * 3 + 2; j++) {
+                        std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[j].c_str(),
+                                    str_v[j].size());
+                        curr_len += str_v[j].size();
+                    }
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, "01", 
2);
+                    curr_len += 2;
+                } else if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "year",
+                                       4)) {
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[i * 3].c_str(),
+                                str_v[i * 3].size());
+                    curr_len += str_v[i * 3].size();
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
"0101", 4);
+                    curr_len += 4;
+                } else {
+                    return Status::Error<ErrorCode::INTERNAL_ERROR>(
+                            "the first argument is range , the second argument 
muse be "
+                            "day/month/year ");
+                }
+                std::memcpy(&res_data[res_offset[i - 1]] + curr_len, "000000", 
6);
+                curr_len += 6;
+                res_offset[i] = res_offset[i - 1] + curr_len;
+            }
+
+            block.get_by_position(result).column = std::move(res);
+            return Status::OK();
+        } else {
+            return Status::Error<ErrorCode::INVALID_ARGUMENT>(
+                    "partition type must be range or list");
+        }
+
+        return Status::OK();
+    }
+
+private:
+    std::u16string string_to_u16string(const std::string& str) const {
+        std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> 
convert;
+        return convert.from_bytes(str);
+    }
+
+    std::string StringToUnicode(const std::u16string& s) const {
+        std::stringstream ss;
+        if (s.length() > 0 && s[0] == '-') {
+            ss << "_";
+        }
+        for (int i = 0; i < s.length(); i++) {
+            char ch = s[i];
+            if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= 
'0' && ch <= '9')) {
+                ss << ch;
+            } else {
+                int unicodeValue = getCodePointAt(s, i);
+                ss << std::hex << unicodeValue;
+            }
+        }
+        return ss.str();
+    }
+    int getCodePointAt(const std::u16string& str, std::size_t index) const {
+        char16_t first = str[index];
+        if ((first >= 0xD800 && first <= 0xDBFF) && (index + 1 < str.size())) {

Review Comment:
   add comment on these magic numbers



##########
be/src/vec/functions/function_string.h:
##########
@@ -356,6 +357,174 @@ class FunctionStrcmp : public IFunction {
     }
 };
 
+class FunctionAutoPartitionName : public IFunction {
+public:
+    static constexpr auto name = "auto_partition_name";
+    static FunctionPtr create() { return 
std::make_shared<FunctionAutoPartitionName>(); }
+    String get_name() const override { return name; }
+    size_t get_number_of_arguments() const override { return 0; }
+    bool is_variadic() const override { return true; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
+        return std::make_shared<DataTypeString>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) const override 
{
+        DCHECK_GE(arguments.size(), 2);
+
+        int argument_size = arguments.size();
+        std::vector<const ColumnString::Chars*> chars_list(argument_size);
+
+        for (int i = 0; i < argument_size; ++i) {
+            const auto& [col, is_const] =
+                    
unpack_if_const(block.get_by_position(arguments[i]).column);
+
+            const auto* col_str = assert_cast<const ColumnString*>(col.get());
+            chars_list[i] = &col_str->get_chars();
+        }
+
+        auto res = ColumnString::create();
+        auto& res_data = res->get_chars();
+        auto& res_offset = res->get_offsets();
+        res_offset.resize(input_rows_count);
+
+        auto compare_str = [&](const char* str1, const char* str2, size_t n) {
+            for (int i = 0; i < n; i++) {
+                if (str1[i] != str2[i]) {
+                    return 0;
+                }
+            }
+            return 1;
+        };
+        if (compare_str(chars_list[0]->raw_data(), "list", 4)) {
+            std::string res_p = "p";
+            for (int i = 0; i < input_rows_count; i++) {
+                int curr_size = 0;
+                for (int j = 1; j < argument_size; j++) {
+                    const std::string 
string_to_unicode(chars_list[j]->raw_data(),
+                                                        chars_list[j]->size());
+                    auto unicode_to_string = 
string_to_u16string(string_to_unicode);
+                    res_p += StringToUnicode(unicode_to_string) +
+                             std::to_string(unicode_to_string.size());
+                }
+                int len = res_p.size();
+                res_data.resize(len + curr_size);
+                std::memcpy(&res_data[res_offset[i - 1]], res_p.c_str(), len);
+                res_offset[i] = res_offset[i - 1] + len;
+            }
+
+            block.get_by_position(result).column = std::move(res);
+            return Status::OK();
+        } else if (compare_str(chars_list[0]->raw_data(), "range", 5)) {
+            if (argument_size != 3) {
+                return Status::Error<ErrorCode::INVALID_ARGUMENT>(
+                        "partition type is range, the argument of size must be 
3");
+            }
+            const auto& [col_partition_type, is_const_col_partition_type] =
+                    
unpack_if_const(block.get_by_position(arguments[1]).column);
+
+            const auto* col_str_partition_type_str =
+                    assert_cast<const ColumnString*>(col_partition_type.get());
+
+            std::string to_split_s(chars_list[2]->raw_data(), 
chars_list[2]->size());
+            std::vector<std::string> str_v;
+            if (to_split_s.size() == input_rows_count * 19) {
+                for (int i = 0; i < to_split_s.size(); i += 19) {
+                    auto vec_res = split(to_split_s.substr(i, 10), "-");
+                    for (const auto& s : vec_res) {
+                        str_v.emplace_back(s);
+                    }
+                }
+            } else {
+                for (int i = 0; i < to_split_s.size(); i += 10) {
+                    auto vec_res = split(to_split_s.substr(i, 10), "-");
+                    for (const auto& s : vec_res) {
+                        str_v.emplace_back(s);
+                    }
+                }
+            }
+            res_data.resize(15 * input_rows_count);
+            for (int i = 0; i < input_rows_count; i++) {
+                int curr_len = 1;
+
+                res_data[res_offset[i - 1]] = 'p';
+                if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "day", 3)) {
+                    for (int j = i * 3; j < i * 3 + 3; j++) {
+                        std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[j].c_str(),
+                                    str_v[j].size());
+                        curr_len += str_v[j].size();
+                    }
+                } else if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "month",
+                                       5)) {
+                    for (int j = i * 3; j < i * 3 + 2; j++) {
+                        std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[j].c_str(),
+                                    str_v[j].size());
+                        curr_len += str_v[j].size();
+                    }
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, "01", 
2);
+                    curr_len += 2;
+                } else if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "year",
+                                       4)) {
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[i * 3].c_str(),
+                                str_v[i * 3].size());
+                    curr_len += str_v[i * 3].size();
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
"0101", 4);
+                    curr_len += 4;
+                } else {
+                    return Status::Error<ErrorCode::INTERNAL_ERROR>(
+                            "the first argument is range , the second argument 
muse be "
+                            "day/month/year ");
+                }
+                std::memcpy(&res_data[res_offset[i - 1]] + curr_len, "000000", 
6);
+                curr_len += 6;
+                res_offset[i] = res_offset[i - 1] + curr_len;
+            }
+
+            block.get_by_position(result).column = std::move(res);
+            return Status::OK();
+        } else {
+            return Status::Error<ErrorCode::INVALID_ARGUMENT>(
+                    "partition type must be range or list");
+        }
+
+        return Status::OK();
+    }
+
+private:
+    std::u16string string_to_u16string(const std::string& str) const {
+        std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> 
convert;
+        return convert.from_bytes(str);
+    }
+
+    std::string StringToUnicode(const std::u16string& s) const {
+        std::stringstream ss;

Review Comment:
   don't use stringstream since it has poor performance 



##########
be/src/vec/functions/function_string.h:
##########
@@ -356,6 +357,174 @@ class FunctionStrcmp : public IFunction {
     }
 };
 
+class FunctionAutoPartitionName : public IFunction {
+public:
+    static constexpr auto name = "auto_partition_name";
+    static FunctionPtr create() { return 
std::make_shared<FunctionAutoPartitionName>(); }
+    String get_name() const override { return name; }
+    size_t get_number_of_arguments() const override { return 0; }
+    bool is_variadic() const override { return true; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
+        return std::make_shared<DataTypeString>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) const override 
{
+        DCHECK_GE(arguments.size(), 2);
+
+        int argument_size = arguments.size();
+        std::vector<const ColumnString::Chars*> chars_list(argument_size);
+
+        for (int i = 0; i < argument_size; ++i) {
+            const auto& [col, is_const] =
+                    
unpack_if_const(block.get_by_position(arguments[i]).column);
+
+            const auto* col_str = assert_cast<const ColumnString*>(col.get());
+            chars_list[i] = &col_str->get_chars();
+        }
+
+        auto res = ColumnString::create();
+        auto& res_data = res->get_chars();
+        auto& res_offset = res->get_offsets();
+        res_offset.resize(input_rows_count);
+
+        auto compare_str = [&](const char* str1, const char* str2, size_t n) {
+            for (int i = 0; i < n; i++) {
+                if (str1[i] != str2[i]) {
+                    return 0;
+                }
+            }
+            return 1;
+        };
+        if (compare_str(chars_list[0]->raw_data(), "list", 4)) {
+            std::string res_p = "p";
+            for (int i = 0; i < input_rows_count; i++) {
+                int curr_size = 0;
+                for (int j = 1; j < argument_size; j++) {
+                    const std::string 
string_to_unicode(chars_list[j]->raw_data(),
+                                                        chars_list[j]->size());
+                    auto unicode_to_string = 
string_to_u16string(string_to_unicode);
+                    res_p += StringToUnicode(unicode_to_string) +
+                             std::to_string(unicode_to_string.size());
+                }
+                int len = res_p.size();
+                res_data.resize(len + curr_size);
+                std::memcpy(&res_data[res_offset[i - 1]], res_p.c_str(), len);
+                res_offset[i] = res_offset[i - 1] + len;
+            }
+
+            block.get_by_position(result).column = std::move(res);
+            return Status::OK();
+        } else if (compare_str(chars_list[0]->raw_data(), "range", 5)) {
+            if (argument_size != 3) {
+                return Status::Error<ErrorCode::INVALID_ARGUMENT>(
+                        "partition type is range, the argument of size must be 
3");
+            }
+            const auto& [col_partition_type, is_const_col_partition_type] =
+                    
unpack_if_const(block.get_by_position(arguments[1]).column);
+
+            const auto* col_str_partition_type_str =
+                    assert_cast<const ColumnString*>(col_partition_type.get());
+
+            std::string to_split_s(chars_list[2]->raw_data(), 
chars_list[2]->size());
+            std::vector<std::string> str_v;
+            if (to_split_s.size() == input_rows_count * 19) {
+                for (int i = 0; i < to_split_s.size(); i += 19) {
+                    auto vec_res = split(to_split_s.substr(i, 10), "-");
+                    for (const auto& s : vec_res) {
+                        str_v.emplace_back(s);
+                    }
+                }
+            } else {
+                for (int i = 0; i < to_split_s.size(); i += 10) {
+                    auto vec_res = split(to_split_s.substr(i, 10), "-");
+                    for (const auto& s : vec_res) {
+                        str_v.emplace_back(s);
+                    }
+                }
+            }
+            res_data.resize(15 * input_rows_count);
+            for (int i = 0; i < input_rows_count; i++) {
+                int curr_len = 1;
+
+                res_data[res_offset[i - 1]] = 'p';
+                if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "day", 3)) {
+                    for (int j = i * 3; j < i * 3 + 3; j++) {
+                        std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[j].c_str(),
+                                    str_v[j].size());
+                        curr_len += str_v[j].size();
+                    }
+                } else if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "month",
+                                       5)) {
+                    for (int j = i * 3; j < i * 3 + 2; j++) {
+                        std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[j].c_str(),
+                                    str_v[j].size());
+                        curr_len += str_v[j].size();
+                    }
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, "01", 
2);
+                    curr_len += 2;
+                } else if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "year",
+                                       4)) {
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[i * 3].c_str(),
+                                str_v[i * 3].size());
+                    curr_len += str_v[i * 3].size();
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
"0101", 4);
+                    curr_len += 4;
+                } else {
+                    return Status::Error<ErrorCode::INTERNAL_ERROR>(
+                            "the first argument is range , the second argument 
muse be "
+                            "day/month/year ");
+                }
+                std::memcpy(&res_data[res_offset[i - 1]] + curr_len, "000000", 
6);

Review Comment:
   do not use `std::memcpy`, just `memcpy`. because we have special 
optimization on it



##########
be/src/vec/functions/function_string.h:
##########
@@ -356,6 +357,174 @@ class FunctionStrcmp : public IFunction {
     }
 };
 
+class FunctionAutoPartitionName : public IFunction {
+public:
+    static constexpr auto name = "auto_partition_name";
+    static FunctionPtr create() { return 
std::make_shared<FunctionAutoPartitionName>(); }
+    String get_name() const override { return name; }
+    size_t get_number_of_arguments() const override { return 0; }
+    bool is_variadic() const override { return true; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
+        return std::make_shared<DataTypeString>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) const override 
{
+        DCHECK_GE(arguments.size(), 2);
+
+        int argument_size = arguments.size();
+        std::vector<const ColumnString::Chars*> chars_list(argument_size);
+
+        for (int i = 0; i < argument_size; ++i) {
+            const auto& [col, is_const] =
+                    
unpack_if_const(block.get_by_position(arguments[i]).column);
+
+            const auto* col_str = assert_cast<const ColumnString*>(col.get());
+            chars_list[i] = &col_str->get_chars();

Review Comment:
   this may be wrong. because it may have `input_row_count` rows or just `1` 
row (for ColumnConst).
   So when you use it anywhere like line405., maybe should `index_check_const`



##########
be/src/vec/functions/function_string.h:
##########
@@ -356,6 +357,174 @@ class FunctionStrcmp : public IFunction {
     }
 };
 
+class FunctionAutoPartitionName : public IFunction {
+public:
+    static constexpr auto name = "auto_partition_name";
+    static FunctionPtr create() { return 
std::make_shared<FunctionAutoPartitionName>(); }
+    String get_name() const override { return name; }
+    size_t get_number_of_arguments() const override { return 0; }
+    bool is_variadic() const override { return true; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
+        return std::make_shared<DataTypeString>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) const override 
{
+        DCHECK_GE(arguments.size(), 2);
+
+        int argument_size = arguments.size();
+        std::vector<const ColumnString::Chars*> chars_list(argument_size);
+
+        for (int i = 0; i < argument_size; ++i) {
+            const auto& [col, is_const] =
+                    
unpack_if_const(block.get_by_position(arguments[i]).column);
+
+            const auto* col_str = assert_cast<const ColumnString*>(col.get());
+            chars_list[i] = &col_str->get_chars();
+        }
+
+        auto res = ColumnString::create();
+        auto& res_data = res->get_chars();
+        auto& res_offset = res->get_offsets();
+        res_offset.resize(input_rows_count);
+
+        auto compare_str = [&](const char* str1, const char* str2, size_t n) {
+            for (int i = 0; i < n; i++) {
+                if (str1[i] != str2[i]) {
+                    return 0;
+                }
+            }
+            return 1;
+        };
+        if (compare_str(chars_list[0]->raw_data(), "list", 4)) {
+            std::string res_p = "p";
+            for (int i = 0; i < input_rows_count; i++) {
+                int curr_size = 0;
+                for (int j = 1; j < argument_size; j++) {
+                    const std::string 
string_to_unicode(chars_list[j]->raw_data(),
+                                                        chars_list[j]->size());
+                    auto unicode_to_string = 
string_to_u16string(string_to_unicode);
+                    res_p += StringToUnicode(unicode_to_string) +
+                             std::to_string(unicode_to_string.size());
+                }
+                int len = res_p.size();
+                res_data.resize(len + curr_size);
+                std::memcpy(&res_data[res_offset[i - 1]], res_p.c_str(), len);
+                res_offset[i] = res_offset[i - 1] + len;
+            }
+
+            block.get_by_position(result).column = std::move(res);
+            return Status::OK();
+        } else if (compare_str(chars_list[0]->raw_data(), "range", 5)) {
+            if (argument_size != 3) {
+                return Status::Error<ErrorCode::INVALID_ARGUMENT>(
+                        "partition type is range, the argument of size must be 
3");
+            }
+            const auto& [col_partition_type, is_const_col_partition_type] =
+                    
unpack_if_const(block.get_by_position(arguments[1]).column);
+
+            const auto* col_str_partition_type_str =
+                    assert_cast<const ColumnString*>(col_partition_type.get());
+
+            std::string to_split_s(chars_list[2]->raw_data(), 
chars_list[2]->size());
+            std::vector<std::string> str_v;
+            if (to_split_s.size() == input_rows_count * 19) {
+                for (int i = 0; i < to_split_s.size(); i += 19) {
+                    auto vec_res = split(to_split_s.substr(i, 10), "-");
+                    for (const auto& s : vec_res) {
+                        str_v.emplace_back(s);
+                    }
+                }
+            } else {
+                for (int i = 0; i < to_split_s.size(); i += 10) {
+                    auto vec_res = split(to_split_s.substr(i, 10), "-");
+                    for (const auto& s : vec_res) {
+                        str_v.emplace_back(s);
+                    }
+                }
+            }
+            res_data.resize(15 * input_rows_count);
+            for (int i = 0; i < input_rows_count; i++) {
+                int curr_len = 1;
+
+                res_data[res_offset[i - 1]] = 'p';
+                if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "day", 3)) {
+                    for (int j = i * 3; j < i * 3 + 3; j++) {
+                        std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[j].c_str(),
+                                    str_v[j].size());
+                        curr_len += str_v[j].size();
+                    }
+                } else if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "month",
+                                       5)) {
+                    for (int j = i * 3; j < i * 3 + 2; j++) {
+                        std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[j].c_str(),
+                                    str_v[j].size());
+                        curr_len += str_v[j].size();
+                    }
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, "01", 
2);
+                    curr_len += 2;
+                } else if 
(compare_str(col_str_partition_type_str->get_chars().raw_data(), "year",
+                                       4)) {
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
str_v[i * 3].c_str(),
+                                str_v[i * 3].size());
+                    curr_len += str_v[i * 3].size();
+                    std::memcpy(&res_data[res_offset[i - 1]] + curr_len, 
"0101", 4);
+                    curr_len += 4;
+                } else {
+                    return Status::Error<ErrorCode::INTERNAL_ERROR>(
+                            "the first argument is range , the second argument 
muse be "
+                            "day/month/year ");
+                }
+                std::memcpy(&res_data[res_offset[i - 1]] + curr_len, "000000", 
6);
+                curr_len += 6;
+                res_offset[i] = res_offset[i - 1] + curr_len;
+            }
+
+            block.get_by_position(result).column = std::move(res);
+            return Status::OK();
+        } else {
+            return Status::Error<ErrorCode::INVALID_ARGUMENT>(
+                    "partition type must be range or list");
+        }
+
+        return Status::OK();
+    }
+
+private:
+    std::u16string string_to_u16string(const std::string& str) const {
+        std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> 
convert;
+        return convert.from_bytes(str);
+    }
+
+    std::string StringToUnicode(const std::u16string& s) const {
+        std::stringstream ss;
+        if (s.length() > 0 && s[0] == '-') {
+            ss << "_";
+        }
+        for (int i = 0; i < s.length(); i++) {
+            char ch = s[i];
+            if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= 
'0' && ch <= '9')) {

Review Comment:
   just use `isdigit` `isalpha`



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to