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


##########
be/src/vec/functions/array/function_array_element.h:
##########
@@ -81,6 +94,79 @@ class FunctionArrayElement : public IFunction {
     }
 
 private:
+    //=========================== map element===========================//
+    ColumnPtr _get_mapped_idx(const ColumnArray& key_column,
+                           const ColumnWithTypeAndName& argument) {
+        if (key_column.get_data().is_column_string()) {
+            return _mapped_key_string(key_column, argument);
+        }
+        return nullptr;
+    }
+
+    ColumnPtr _get_mapped_value(const ColumnArray& val_column,
+                                const IColumn& matched_indices,
+                                const UInt8* src_null_map,
+                                UInt8* dst_null_map) {
+        const UInt8* nested_null_map = nullptr;
+        ColumnPtr nested_column = nullptr;
+        if (is_column_nullable(val_column.get_data())) {
+            const auto& nested_null_column =
+                    reinterpret_cast<const 
ColumnNullable&>(val_column.get_data());
+            nested_null_map = 
nested_null_column.get_null_map_column().get_data().data();
+            nested_column = nested_null_column.get_nested_column_ptr();
+        } else {
+            nested_column = val_column.get_data_ptr();
+        }
+        if (check_column<ColumnInt8>(nested_column)) {
+            return _execute_number<ColumnInt8>(val_column.get_offsets(), 
*nested_column,
+                                                src_null_map, matched_indices,
+                                                nested_null_map, dst_null_map);
+        } else if (check_column<ColumnInt32>(nested_column)) {
+            _execute_number<ColumnInt32>(val_column.get_offsets(), 
*nested_column,
+                                        src_null_map, matched_indices,
+                                        nested_null_map, dst_null_map);
+        }
+        return nullptr;
+    }
+
+    ColumnPtr _mapped_key_string(const ColumnArray& column,
+                            const ColumnWithTypeAndName& argument) {
+        auto right_column = argument.column->convert_to_full_column_if_const();
+        const ColumnString& match_key = reinterpret_cast<const 
ColumnString&>(*right_column);
+        const ColumnArray::Offsets64& offsets = column.get_offsets();
+        ColumnPtr nested_ptr = nullptr;
+        if (is_column_nullable(column.get_data())) {
+            nested_ptr = reinterpret_cast<const 
ColumnNullable&>(column.get_data()).get_nested_column_ptr();
+        } else {
+            nested_ptr = column.get_data_ptr();
+        }
+        const ColumnString& nested_key = reinterpret_cast<const 
ColumnString&>(*nested_ptr);
+        size_t rows = offsets.size();
+        // prepare return data
+        auto matched_indices = ColumnVector<Int8>::create();
+        matched_indices->reserve(rows);
+
+        for (size_t i = 0; i < rows; i++)
+        {
+            bool matched = false;
+            size_t begin = offsets[i - 1];
+            size_t end = offsets[i];
+            for (size_t j = begin; j < end; j++) {
+                if (nested_key.get_data_at(j) == match_key.get_data_at(i)) {

Review Comment:
   done!



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