zclllyybb commented on code in PR #34258: URL: https://github.com/apache/doris/pull/34258#discussion_r1582202479
########## be/src/vec/functions/function_string.h: ########## @@ -356,6 +357,149 @@ 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); + auto res = ColumnString::create(); + auto& res_data = res->get_chars(); + auto& res_offset = res->get_offsets(); + + 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 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 (argument_size == 2) { + if (!compare_str(chars_list[0]->raw_data(), "list", 4)) { + return Status::Error<ErrorCode::INTERNAL_ERROR>( Review Comment: use `INVALID_ARGUMENT` instead -- 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