amorynan commented on code in PR #29812:
URL: https://github.com/apache/doris/pull/29812#discussion_r1450009453


##########
be/src/vec/functions/function_ip.h:
##########
@@ -832,4 +835,128 @@ class FunctionIsIPAddressInRange : public IFunction {
     }
 };
 
+class FunctionIPv6CIDRToRange : public IFunction {
+public:
+    static constexpr auto name = "ipv6_cidr_to_range";
+    static FunctionPtr create() { return 
std::make_shared<FunctionIPv6CIDRToRange>(); }
+
+    String get_name() const override { return name; }
+
+    size_t get_number_of_arguments() const override { return 2; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
+        const auto& ipv6_type = arguments[0];
+        if (!is_string(remove_nullable(ipv6_type)) && 
!is_ipv6(remove_nullable(ipv6_type))) {
+            throw Exception(
+                    ErrorCode::INVALID_ARGUMENT,
+                    "Illegal type {} of first argument of function {}, 
expected String or IPv6",
+                    ipv6_type->get_name(), get_name());
+        }
+        const auto& cidr_type = arguments[1];
+        if (!is_integer(remove_nullable(cidr_type))) {
+            throw Exception(ErrorCode::INVALID_ARGUMENT,
+                            "Illegal type {} of second argument of function 
{}, expected Integer",
+                            cidr_type->get_name(), get_name());
+        }
+        DataTypePtr element = std::make_shared<DataTypeIPv6>();
+        return make_nullable(std::make_shared<DataTypeStruct>(DataTypes 
{element, element},
+                                                              Strings {"min", 
"max"}));
+    }
+
+    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& addr_column = block.get_by_position(arguments[0]).column;
+        ColumnPtr& cidr_column = block.get_by_position(arguments[1]).column;
+        const IColumn* cidr_col = nullptr;
+        const NullMap* cidr_nullmap = nullptr;
+        ColumnPtr col_res = nullptr;
+
+        if (cidr_column->is_nullable()) {

Review Comment:
   do not use columntype to judge what type of current data, use 
block.get_data_type



-- 
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