zclllyybb commented on code in PR #33243: URL: https://github.com/apache/doris/pull/33243#discussion_r1564640053
########## be/src/vec/functions/function_string.h: ########## @@ -3914,4 +3914,138 @@ class FunctionIntToChar : public IFunction { #endif } }; + +class FunctionStrInsert : public IFunction { +public: + static constexpr auto name = "str_insert"; + static FunctionPtr create() { return std::make_shared<FunctionStrInsert>(); } + String get_name() const override { return name; } + size_t get_number_of_arguments() const override { return 4; } + + 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_EQ(arguments.size(), 4); + + bool col_const[4]; + ColumnPtr argument_columns[4]; + for (int i = 0; i < 4; ++i) { + std::tie(argument_columns[i], col_const[i]) = + unpack_if_const(block.get_by_position(arguments[i]).column); + } + const auto* col_origin = assert_cast<const ColumnString*>(argument_columns[0].get()); + + const auto* col_pos = assert_cast<const ColumnVector<Int32>*>(argument_columns[1].get()) + ->get_data() + .data(); + const auto* col_len = assert_cast<const ColumnVector<Int32>*>(argument_columns[2].get()) + ->get_data() + .data(); + const auto* col_insert = assert_cast<const ColumnString*>(argument_columns[3].get()); + + ColumnString::MutablePtr col_res = ColumnString::create(); + + if (col_const[1] && col_const[2] && col_const[3]) { + vector_const(col_origin, col_pos, col_len, col_insert, col_res, col_const[0], + input_rows_count); + } else if (col_const[1]) { Review Comment: col1 is const is not a high probability or something to keep an eye on. don't support this -- 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