HappenLee commented on code in PR #39828:
URL: https://github.com/apache/doris/pull/39828#discussion_r1739618332


##########
be/src/vec/functions/function_cast.h:
##########
@@ -1482,6 +1482,43 @@ class PreparedFunctionCast : public PreparedFunctionImpl 
{
     const char* name;
 };
 
+template <typename FromDataType, typename Name>
+struct ConvertToIPv6 {
+    template <typename Additions = void*>
+    static Status execute(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                          size_t result, size_t input_rows_count,
+                          Additions additions [[maybe_unused]] = Additions()) {
+        using ColVecTo = ColumnIPv6;
+        const IColumn* col_from = 
block.get_by_position(arguments[0]).column.get();
+        if (const auto* col_from_ipv4 = 
check_and_get_column<ColumnIPv4>(col_from)) {
+            size_t row = input_rows_count;
+            typename ColVecTo::MutablePtr col_to = ColVecTo::create(row);
+            typename ColVecTo::Container& vec_to = col_to->get_data();
+            const auto& ipv4_column_data = col_from_ipv4->get_data();
+
+            ColumnUInt8::MutablePtr col_null_map_to;
+            ColumnUInt8::Container* vec_null_map_to [[maybe_unused]] = nullptr;
+            col_null_map_to = ColumnUInt8::create(row, 0);
+            vec_null_map_to = &col_null_map_to->get_data();
+            for (size_t i = 0; i < row; ++i) {
+                map_ipv4_to_ipv6(ipv4_column_data[i], 
reinterpret_cast<UInt8*>(&vec_to[i]));
+            }
+            block.get_by_position(result).column =

Review Comment:
   why ipv4 cast to ipv6 always return nullable?



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