superdiaodiao commented on code in PR #27342: URL: https://github.com/apache/doris/pull/27342#discussion_r1411596595
########## be/src/vec/functions/function_ip.h: ########## @@ -250,4 +252,98 @@ class FunctionIPv4StringToNum : public IFunction { } }; +class FunctionIPv6NumToString : public IFunction { +public: + static constexpr auto name = "ipv6numtostring"; + static FunctionPtr create() { return std::make_shared<FunctionIPv6NumToString>(); } + + String get_name() const override { return name; } + + size_t get_number_of_arguments() const override { return 1; } + + DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { + const auto* arg_string = check_and_get_data_type<DataTypeString>(arguments[0].get()); + const auto* arg_ipv6 = check_and_get_data_type<DataTypeIPv6>(arguments[0].get()); + if (!arg_ipv6 && !(arg_string)) + throw Exception(ErrorCode::INVALID_ARGUMENT, + "Illegal type {} of argument of function {}, expected IPv6 or String", + arguments[0]->get_name(), get_name()); + + return make_nullable(std::make_shared<DataTypeString>()); + } + + bool use_default_implementation_for_nulls() const override { return true; } + + Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, + size_t result, size_t input_rows_count) const override { + ColumnPtr column = block.get_by_position(arguments[0]).column; + const auto* col_ipv6 = check_and_get_column<ColumnIPv6>(column.get()); Review Comment: OK, more reasonable. -- 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