You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "bobhan1 (via GitHub)" <gi...@apache.org> on 2023/03/07 13:34:39 UTC

[GitHub] [doris] bobhan1 opened a new pull request, #17541: [feature](array function) add support for array_enumerate_uniq

bobhan1 opened a new pull request, #17541:
URL: https://github.com/apache/doris/pull/17541

   # Proposed changes
   
   Issue Number: #17448 
   
   ## Problem summary
   
   add support for `array_enumerate_uniq()`
   
   ## Checklist(Required)
   
   * [ ] Does it affect the original behavior
   * [ ] Has unit tests been added
   * [ ] Has document been added or modified
   * [ ] Does it need to update dependencies
   * [ ] Is this PR support rollback (If NO, please explain WHY)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on a diff in pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #17541:
URL: https://github.com/apache/doris/pull/17541#discussion_r1127871294


##########
be/src/vec/functions/array/function_array_enumerate_uniq.cpp:
##########
@@ -0,0 +1,250 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <vec/columns/column_array.h>
+#include <vec/columns/column_nullable.h>
+#include <vec/columns/columns_number.h>
+#include <vec/common/columns_hashing.h>
+#include <vec/common/hash_table/hash_map.h>
+#include <vec/data_types/data_type_array.h>
+#include <vec/data_types/data_type_number.h>
+#include <vec/functions/function.h>
+#include <vec/functions/function_helpers.h>
+#include <vec/functions/simple_function_factory.h>
+
+namespace doris::vectorized {
+
+class FunctionArrayEnumerateUniq : public IFunction {
+private:
+    static constexpr size_t INITIAL_SIZE_DEGREE = 5;
+
+public:
+    using NullMapType = PaddedPODArray<UInt8>;
+    static constexpr auto name = "array_enumerate_uniq";
+    static FunctionPtr create() { return std::make_shared<FunctionArrayEnumerateUniq>(); }
+    String get_name() const override { return name; }
+    bool is_variadic() const override { return true; }
+    size_t get_number_of_arguments() const override { return 1; }
+    bool use_default_implementation_for_nulls() const override { return false; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
+        if (arguments.empty()) {
+            LOG(FATAL) << "Incorrect number of arguments for array_enumerate_uniq function";
+        }
+        bool is_nested_nullable = false;
+        for (size_t i = 0; i < arguments.size(); ++i) {
+            const DataTypeArray* array_type =
+                    check_and_get_data_type<DataTypeArray>(remove_nullable(arguments[i]).get());
+            if (!array_type) {
+                LOG(FATAL) << "The " << i
+                           << "-th argument for function " + get_name() +
+                                      " must be an array but it has type " +
+                                      arguments[i]->get_name() + ".";
+            }
+            if (i == 0) {
+                is_nested_nullable = array_type->get_nested_type()->is_nullable();
+            }
+        }
+
+        auto return_nested_type = std::make_shared<DataTypeInt64>();
+        DataTypePtr return_type = std::make_shared<DataTypeArray>(
+                is_nested_nullable ? make_nullable(return_nested_type) : return_nested_type);
+        if (arguments.size() == 1 && arguments[0]->is_nullable()) {
+            return_type = make_nullable(return_type);
+        }
+        return return_type;
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        ColumnRawPtrs data_columns(arguments.size());
+        const ColumnArray::Offsets64* offsets = nullptr;
+        ColumnPtr src_offsets;
+        Columns src_columns; // to keep ownership
+
+        const ColumnArray* first_column_array = nullptr;
+
+        for (size_t i = 0; i < arguments.size(); i++) {
+            src_columns.emplace_back(
+                    block.get_by_position(arguments[i]).column->convert_to_full_column_if_const());
+            ColumnPtr& cur_column = src_columns[i];
+            const ColumnArray* array =
+                    check_and_get_column<ColumnArray>(remove_nullable(cur_column->get_ptr()));
+            if (!array) {
+                return Status::RuntimeError(
+                        fmt::format("Illegal column {}, of first argument of function {}",
+                                    cur_column->get_name(), get_name()));
+            }
+
+            const ColumnArray::Offsets64& cur_offsets = array->get_offsets();
+            if (i == 0) {
+                first_column_array = array;
+                offsets = &cur_offsets;
+                src_offsets = array->get_offsets_ptr();
+            } else if (*offsets != cur_offsets) {
+                return Status::RuntimeError(fmt::format(
+                        "lengths of all arrays of fucntion {} must be equal.", get_name()));
+            }
+            const auto* array_data = &array->get_data();
+            data_columns[i] = array_data;
+        }
+
+        const NullMapType* null_map = nullptr;
+        if (arguments.size() == 1 && data_columns[0]->is_nullable()) {
+            const ColumnNullable* nullable = check_and_get_column<ColumnNullable>(*data_columns[0]);
+            data_columns[0] = nullable->get_nested_column_ptr();
+            null_map = &nullable->get_null_map_column().get_data();
+        }
+
+        auto dst_nested_column = ColumnInt64::create();
+        ColumnInt64::Container& dst_values = dst_nested_column->get_data();
+        dst_values.resize(offsets->back());
+
+        if (arguments.size() == 1) {
+            DataTypePtr src_column_type = block.get_by_position(arguments[0]).type;
+            if (src_column_type->is_nullable()) {
+                src_column_type =
+                        assert_cast<const DataTypeNullable&>(*src_column_type).get_nested_type();
+            }
+            auto nested_type =
+                    assert_cast<const DataTypeArray&>(*src_column_type).get_nested_type();
+            WhichDataType which(remove_nullable(nested_type));
+            if (which.is_uint8()) {
+                _execute_number<ColumnUInt8>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int8()) {
+                _execute_number<ColumnInt8>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int16()) {
+                _execute_number<ColumnInt16>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int32()) {
+                _execute_number<ColumnInt32>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int64()) {
+                _execute_number<ColumnInt64>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int128()) {
+                _execute_number<ColumnInt128>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_float32()) {
+                _execute_number<ColumnFloat32>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_float64()) {
+                _execute_number<ColumnFloat64>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date()) {
+                _execute_number<ColumnDate>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_time()) {
+                _execute_number<ColumnDateTime>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_v2()) {
+                _execute_number<ColumnDateV2>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_time_v2()) {
+                _execute_number<ColumnDateTimeV2>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_decimal128()) {
+                _execute_number<ColumnDecimal128>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_string()) {
+                _execute_string(data_columns, *offsets, null_map, dst_values);
+            }
+        } else {
+            using HashMapContainer =
+                    HashMapWithStackMemory<UInt128, Int64, UInt128TrivialHash, INITIAL_SIZE_DEGREE>;
+            using HashMethod = ColumnsHashing::HashMethodHashed<DataTypeUInt64, Int64, false>;
+            _execute_by_hash<HashMapContainer, HashMethod, false>(data_columns, *offsets, nullptr,
+                                                                  dst_values);
+        }
+
+        ColumnPtr nested_column = dst_nested_column->get_ptr();
+        if (first_column_array->get_data().is_nullable()) {
+            nested_column = ColumnNullable::create(nested_column,
+                                                   ColumnUInt8::create(nested_column->size(), 0));
+        }
+        ColumnPtr res_column = ColumnArray::create(std::move(nested_column), src_offsets);

Review Comment:
   warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
   
   ```suggestion
           ColumnPtr res_column = ColumnArray::create(nested_column, src_offsets);
   ```
   



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459699897

   I run the regression test locally and it failed at an irrelevant test suit:
   ```
   2023-03-08 16:04:13.763 INFO [main] (RegressionTest.groovy:277) - Failure suites:
   /home/baohan/projects/doris/regression-test/suites/query_p0/sql_functions/array_functions/sql/q03.sql: group=default,p0, name=q03
   ```
   `/doris/regression-test/suites/query_p0/sql_functions/array_functions/sql/q03.sql`:
   ```
   DROP TABLE IF EXISTS array_insert_select_test;
   CREATE TABLE IF NOT EXISTS array_insert_select_test (id int, c_array array<int(11)>) ENGINE = Olap DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES('replication_num' = '1');
   insert into array_insert_select_test select k1, collect_list(k3) from test_query_db.test group by k1;
   select c_array from array_insert_select_test;
   ```
   Should I do the rebase?


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] eldenmoon commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "eldenmoon (via GitHub)" <gi...@apache.org>.
eldenmoon commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459703899

   @bobhan1 you could ignore `array_functions/sql/q03.sql` while run local, since the query rely on a table from load related regression test case


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459186617

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459966285

   run p1


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] eldenmoon commented on a diff in pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "eldenmoon (via GitHub)" <gi...@apache.org>.
eldenmoon commented on code in PR #17541:
URL: https://github.com/apache/doris/pull/17541#discussion_r1128882706


##########
docs/en/docs/sql-manual/sql-functions/array-functions/array_enumerate_uniq.md:
##########
@@ -0,0 +1,59 @@
+---
+{
+    "title": "array_enumerate_uniq",
+    "language": "en"
+}
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## array_enumerate
+
+<version since="1.2.3">
+
+array_enumerate_uniq
+
+</version>
+
+### description
+
+Returns an array the same size as the source array, indicating for each element what its position is among elements with the same value. For example, arrayEnumerateUniq([1, 2, 1, 4]) = [1, 1, 2, 1].
+The arrayEnumerateUniq function can take multiple arrays of the same size as arguments. In this case, uniqueness is considered for tuples of elements in the same positions in all the arrays. For example, arrayEnumerateUniq([1, 2, 1, 1, 2], [2, 1, 2, 2, 1]) = [1, 1, 2, 3, 2].
+
+### example
+
+```shell
+mysql> select k2, array_enumerate_uniq([1, 2, 3, 1, 2, 3]);
++-----------------------------------------------------+
+| array_popback(ARRAY(1, 2, 3, 1, 2, 3))              |

Review Comment:
   array_popback?



##########
docs/en/docs/sql-manual/sql-functions/array-functions/array_enumerate_uniq.md:
##########
@@ -0,0 +1,59 @@
+---
+{
+    "title": "array_enumerate_uniq",
+    "language": "en"
+}
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## array_enumerate
+
+<version since="1.2.3">
+
+array_enumerate_uniq
+
+</version>
+
+### description
+
+Returns an array the same size as the source array, indicating for each element what its position is among elements with the same value. For example, arrayEnumerateUniq([1, 2, 1, 4]) = [1, 1, 2, 1].
+The arrayEnumerateUniq function can take multiple arrays of the same size as arguments. In this case, uniqueness is considered for tuples of elements in the same positions in all the arrays. For example, arrayEnumerateUniq([1, 2, 1, 1, 2], [2, 1, 2, 2, 1]) = [1, 1, 2, 3, 2].

Review Comment:
   `array_enumerate_uniq` lower case



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459667004

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on a diff in pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on code in PR #17541:
URL: https://github.com/apache/doris/pull/17541#discussion_r1130261514


##########
be/src/vec/functions/array/function_array_enumerate_uniq.cpp:
##########
@@ -0,0 +1,250 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <vec/columns/column_array.h>
+#include <vec/columns/column_nullable.h>
+#include <vec/columns/columns_number.h>
+#include <vec/common/columns_hashing.h>
+#include <vec/common/hash_table/hash_map.h>
+#include <vec/data_types/data_type_array.h>
+#include <vec/data_types/data_type_number.h>
+#include <vec/functions/function.h>
+#include <vec/functions/function_helpers.h>
+#include <vec/functions/simple_function_factory.h>
+
+namespace doris::vectorized {
+
+class FunctionArrayEnumerateUniq : public IFunction {
+private:
+    static constexpr size_t INITIAL_SIZE_DEGREE = 5;
+
+public:
+    using NullMapType = PaddedPODArray<UInt8>;
+    static constexpr auto name = "array_enumerate_uniq";
+    static FunctionPtr create() { return std::make_shared<FunctionArrayEnumerateUniq>(); }
+    String get_name() const override { return name; }
+    bool is_variadic() const override { return true; }
+    size_t get_number_of_arguments() const override { return 1; }
+    bool use_default_implementation_for_nulls() const override { return false; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
+        if (arguments.empty()) {
+            LOG(FATAL) << "Incorrect number of arguments for array_enumerate_uniq function";
+        }
+        bool is_nested_nullable = false;
+        for (size_t i = 0; i < arguments.size(); ++i) {
+            const DataTypeArray* array_type =
+                    check_and_get_data_type<DataTypeArray>(remove_nullable(arguments[i]).get());
+            if (!array_type) {
+                LOG(FATAL) << "The " << i
+                           << "-th argument for function " + get_name() +
+                                      " must be an array but it has type " +
+                                      arguments[i]->get_name() + ".";
+            }
+            if (i == 0) {
+                is_nested_nullable = array_type->get_nested_type()->is_nullable();
+            }
+        }
+
+        auto return_nested_type = std::make_shared<DataTypeInt64>();
+        DataTypePtr return_type = std::make_shared<DataTypeArray>(
+                is_nested_nullable ? make_nullable(return_nested_type) : return_nested_type);
+        if (arguments.size() == 1 && arguments[0]->is_nullable()) {
+            return_type = make_nullable(return_type);
+        }
+        return return_type;
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        ColumnRawPtrs data_columns(arguments.size());
+        const ColumnArray::Offsets64* offsets = nullptr;
+        ColumnPtr src_offsets;
+        Columns src_columns; // to keep ownership
+
+        const ColumnArray* first_column_array = nullptr;
+
+        for (size_t i = 0; i < arguments.size(); i++) {
+            src_columns.emplace_back(
+                    block.get_by_position(arguments[i]).column->convert_to_full_column_if_const());
+            ColumnPtr& cur_column = src_columns[i];
+            const ColumnArray* array =
+                    check_and_get_column<ColumnArray>(remove_nullable(cur_column->get_ptr()));
+            if (!array) {
+                return Status::RuntimeError(
+                        fmt::format("Illegal column {}, of first argument of function {}",
+                                    cur_column->get_name(), get_name()));
+            }
+
+            const ColumnArray::Offsets64& cur_offsets = array->get_offsets();
+            if (i == 0) {
+                first_column_array = array;
+                offsets = &cur_offsets;
+                src_offsets = array->get_offsets_ptr();
+            } else if (*offsets != cur_offsets) {
+                return Status::RuntimeError(fmt::format(
+                        "lengths of all arrays of fucntion {} must be equal.", get_name()));
+            }
+            const auto* array_data = &array->get_data();
+            data_columns[i] = array_data;
+        }
+
+        const NullMapType* null_map = nullptr;
+        if (arguments.size() == 1 && data_columns[0]->is_nullable()) {
+            const ColumnNullable* nullable = check_and_get_column<ColumnNullable>(*data_columns[0]);
+            data_columns[0] = nullable->get_nested_column_ptr();
+            null_map = &nullable->get_null_map_column().get_data();
+        }
+
+        auto dst_nested_column = ColumnInt64::create();
+        ColumnInt64::Container& dst_values = dst_nested_column->get_data();
+        dst_values.resize(offsets->back());
+
+        if (arguments.size() == 1) {
+            DataTypePtr src_column_type = block.get_by_position(arguments[0]).type;
+            if (src_column_type->is_nullable()) {
+                src_column_type =
+                        assert_cast<const DataTypeNullable&>(*src_column_type).get_nested_type();
+            }
+            auto nested_type =
+                    assert_cast<const DataTypeArray&>(*src_column_type).get_nested_type();
+            WhichDataType which(remove_nullable(nested_type));
+            if (which.is_uint8()) {
+                _execute_number<ColumnUInt8>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int8()) {
+                _execute_number<ColumnInt8>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int16()) {
+                _execute_number<ColumnInt16>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int32()) {
+                _execute_number<ColumnInt32>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int64()) {
+                _execute_number<ColumnInt64>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int128()) {
+                _execute_number<ColumnInt128>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_float32()) {
+                _execute_number<ColumnFloat32>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_float64()) {
+                _execute_number<ColumnFloat64>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date()) {
+                _execute_number<ColumnDate>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_time()) {
+                _execute_number<ColumnDateTime>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_v2()) {
+                _execute_number<ColumnDateV2>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_time_v2()) {
+                _execute_number<ColumnDateTimeV2>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_decimal128()) {

Review Comment:
   I want to make this PR merged first and later make another PR to add sppport for decimalv3. Because the regression test is too difficult to pass (it always failed due to shortage of memory, network problems, etc). If latere checks of this PR fails, I'll add them in this PR.



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] hello-stephen commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459667311

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 33.95 seconds
    stream load tsv:          460 seconds loaded 74807831229 Bytes, about 155 MB/s
    stream load json:         39 seconds loaded 2358488459 Bytes, about 57 MB/s
    stream load orc:          74 seconds loaded 1101869774 Bytes, about 14 MB/s
    stream load parquet:          31 seconds loaded 861443392 Bytes, about 26 MB/s
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20230308073754_clickbench_pr_110629.html


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yukang-Lian commented on a diff in pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "Yukang-Lian (via GitHub)" <gi...@apache.org>.
Yukang-Lian commented on code in PR #17541:
URL: https://github.com/apache/doris/pull/17541#discussion_r1129462379


##########
be/src/vec/functions/array/function_array_enumerate_uniq.cpp:
##########
@@ -0,0 +1,250 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <vec/columns/column_array.h>
+#include <vec/columns/column_nullable.h>
+#include <vec/columns/columns_number.h>
+#include <vec/common/columns_hashing.h>
+#include <vec/common/hash_table/hash_map.h>
+#include <vec/data_types/data_type_array.h>
+#include <vec/data_types/data_type_number.h>
+#include <vec/functions/function.h>
+#include <vec/functions/function_helpers.h>
+#include <vec/functions/simple_function_factory.h>
+
+namespace doris::vectorized {
+
+class FunctionArrayEnumerateUniq : public IFunction {
+private:
+    static constexpr size_t INITIAL_SIZE_DEGREE = 5;
+
+public:
+    using NullMapType = PaddedPODArray<UInt8>;
+    static constexpr auto name = "array_enumerate_uniq";
+    static FunctionPtr create() { return std::make_shared<FunctionArrayEnumerateUniq>(); }
+    String get_name() const override { return name; }
+    bool is_variadic() const override { return true; }
+    size_t get_number_of_arguments() const override { return 1; }
+    bool use_default_implementation_for_nulls() const override { return false; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
+        if (arguments.empty()) {
+            LOG(FATAL) << "Incorrect number of arguments for array_enumerate_uniq function";
+        }
+        bool is_nested_nullable = false;
+        for (size_t i = 0; i < arguments.size(); ++i) {
+            const DataTypeArray* array_type =
+                    check_and_get_data_type<DataTypeArray>(remove_nullable(arguments[i]).get());
+            if (!array_type) {
+                LOG(FATAL) << "The " << i
+                           << "-th argument for function " + get_name() +
+                                      " must be an array but it has type " +
+                                      arguments[i]->get_name() + ".";
+            }
+            if (i == 0) {
+                is_nested_nullable = array_type->get_nested_type()->is_nullable();
+            }
+        }
+
+        auto return_nested_type = std::make_shared<DataTypeInt64>();
+        DataTypePtr return_type = std::make_shared<DataTypeArray>(
+                is_nested_nullable ? make_nullable(return_nested_type) : return_nested_type);
+        if (arguments.size() == 1 && arguments[0]->is_nullable()) {
+            return_type = make_nullable(return_type);
+        }
+        return return_type;
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        ColumnRawPtrs data_columns(arguments.size());
+        const ColumnArray::Offsets64* offsets = nullptr;
+        ColumnPtr src_offsets;
+        Columns src_columns; // to keep ownership
+
+        const ColumnArray* first_column_array = nullptr;
+
+        for (size_t i = 0; i < arguments.size(); i++) {
+            src_columns.emplace_back(
+                    block.get_by_position(arguments[i]).column->convert_to_full_column_if_const());
+            ColumnPtr& cur_column = src_columns[i];
+            const ColumnArray* array =
+                    check_and_get_column<ColumnArray>(remove_nullable(cur_column->get_ptr()));
+            if (!array) {
+                return Status::RuntimeError(
+                        fmt::format("Illegal column {}, of first argument of function {}",
+                                    cur_column->get_name(), get_name()));
+            }
+
+            const ColumnArray::Offsets64& cur_offsets = array->get_offsets();
+            if (i == 0) {
+                first_column_array = array;
+                offsets = &cur_offsets;
+                src_offsets = array->get_offsets_ptr();
+            } else if (*offsets != cur_offsets) {
+                return Status::RuntimeError(fmt::format(
+                        "lengths of all arrays of fucntion {} must be equal.", get_name()));
+            }
+            const auto* array_data = &array->get_data();
+            data_columns[i] = array_data;
+        }
+
+        const NullMapType* null_map = nullptr;
+        if (arguments.size() == 1 && data_columns[0]->is_nullable()) {
+            const ColumnNullable* nullable = check_and_get_column<ColumnNullable>(*data_columns[0]);
+            data_columns[0] = nullable->get_nested_column_ptr();
+            null_map = &nullable->get_null_map_column().get_data();
+        }
+
+        auto dst_nested_column = ColumnInt64::create();
+        ColumnInt64::Container& dst_values = dst_nested_column->get_data();
+        dst_values.resize(offsets->back());
+
+        if (arguments.size() == 1) {
+            DataTypePtr src_column_type = block.get_by_position(arguments[0]).type;
+            if (src_column_type->is_nullable()) {
+                src_column_type =
+                        assert_cast<const DataTypeNullable&>(*src_column_type).get_nested_type();
+            }
+            auto nested_type =
+                    assert_cast<const DataTypeArray&>(*src_column_type).get_nested_type();
+            WhichDataType which(remove_nullable(nested_type));
+            if (which.is_uint8()) {
+                _execute_number<ColumnUInt8>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int8()) {
+                _execute_number<ColumnInt8>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int16()) {
+                _execute_number<ColumnInt16>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int32()) {
+                _execute_number<ColumnInt32>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int64()) {
+                _execute_number<ColumnInt64>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int128()) {
+                _execute_number<ColumnInt128>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_float32()) {
+                _execute_number<ColumnFloat32>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_float64()) {
+                _execute_number<ColumnFloat64>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date()) {
+                _execute_number<ColumnDate>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_time()) {
+                _execute_number<ColumnDateTime>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_v2()) {
+                _execute_number<ColumnDateV2>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_time_v2()) {
+                _execute_number<ColumnDateTimeV2>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_decimal128()) {

Review Comment:
   we need to suppport decimalv3 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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1462097001

   I wonder why the following checks are not triggered.


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459625090

   run buildall


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459723054

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1460185773

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1458191955

   run buildall


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459907739

   Does the number of checks depend on the cheklist above?


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1460018867

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1460132167

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459793216

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1459113175

   run p0


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] yiguolei merged pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "yiguolei (via GitHub)" <gi...@apache.org>.
yiguolei merged PR #17541:
URL: https://github.com/apache/doris/pull/17541


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yukang-Lian commented on a diff in pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "Yukang-Lian (via GitHub)" <gi...@apache.org>.
Yukang-Lian commented on code in PR #17541:
URL: https://github.com/apache/doris/pull/17541#discussion_r1130414090


##########
be/src/vec/functions/array/function_array_enumerate_uniq.cpp:
##########
@@ -0,0 +1,250 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <vec/columns/column_array.h>
+#include <vec/columns/column_nullable.h>
+#include <vec/columns/columns_number.h>
+#include <vec/common/columns_hashing.h>
+#include <vec/common/hash_table/hash_map.h>
+#include <vec/data_types/data_type_array.h>
+#include <vec/data_types/data_type_number.h>
+#include <vec/functions/function.h>
+#include <vec/functions/function_helpers.h>
+#include <vec/functions/simple_function_factory.h>
+
+namespace doris::vectorized {
+
+class FunctionArrayEnumerateUniq : public IFunction {
+private:
+    static constexpr size_t INITIAL_SIZE_DEGREE = 5;
+
+public:
+    using NullMapType = PaddedPODArray<UInt8>;
+    static constexpr auto name = "array_enumerate_uniq";
+    static FunctionPtr create() { return std::make_shared<FunctionArrayEnumerateUniq>(); }
+    String get_name() const override { return name; }
+    bool is_variadic() const override { return true; }
+    size_t get_number_of_arguments() const override { return 1; }
+    bool use_default_implementation_for_nulls() const override { return false; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
+        if (arguments.empty()) {
+            LOG(FATAL) << "Incorrect number of arguments for array_enumerate_uniq function";
+        }
+        bool is_nested_nullable = false;
+        for (size_t i = 0; i < arguments.size(); ++i) {
+            const DataTypeArray* array_type =
+                    check_and_get_data_type<DataTypeArray>(remove_nullable(arguments[i]).get());
+            if (!array_type) {
+                LOG(FATAL) << "The " << i
+                           << "-th argument for function " + get_name() +
+                                      " must be an array but it has type " +
+                                      arguments[i]->get_name() + ".";
+            }
+            if (i == 0) {
+                is_nested_nullable = array_type->get_nested_type()->is_nullable();
+            }
+        }
+
+        auto return_nested_type = std::make_shared<DataTypeInt64>();
+        DataTypePtr return_type = std::make_shared<DataTypeArray>(
+                is_nested_nullable ? make_nullable(return_nested_type) : return_nested_type);
+        if (arguments.size() == 1 && arguments[0]->is_nullable()) {
+            return_type = make_nullable(return_type);
+        }
+        return return_type;
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        ColumnRawPtrs data_columns(arguments.size());
+        const ColumnArray::Offsets64* offsets = nullptr;
+        ColumnPtr src_offsets;
+        Columns src_columns; // to keep ownership
+
+        const ColumnArray* first_column_array = nullptr;
+
+        for (size_t i = 0; i < arguments.size(); i++) {
+            src_columns.emplace_back(
+                    block.get_by_position(arguments[i]).column->convert_to_full_column_if_const());
+            ColumnPtr& cur_column = src_columns[i];
+            const ColumnArray* array =
+                    check_and_get_column<ColumnArray>(remove_nullable(cur_column->get_ptr()));
+            if (!array) {
+                return Status::RuntimeError(
+                        fmt::format("Illegal column {}, of first argument of function {}",
+                                    cur_column->get_name(), get_name()));
+            }
+
+            const ColumnArray::Offsets64& cur_offsets = array->get_offsets();
+            if (i == 0) {
+                first_column_array = array;
+                offsets = &cur_offsets;
+                src_offsets = array->get_offsets_ptr();
+            } else if (*offsets != cur_offsets) {
+                return Status::RuntimeError(fmt::format(
+                        "lengths of all arrays of fucntion {} must be equal.", get_name()));
+            }
+            const auto* array_data = &array->get_data();
+            data_columns[i] = array_data;
+        }
+
+        const NullMapType* null_map = nullptr;
+        if (arguments.size() == 1 && data_columns[0]->is_nullable()) {
+            const ColumnNullable* nullable = check_and_get_column<ColumnNullable>(*data_columns[0]);
+            data_columns[0] = nullable->get_nested_column_ptr();
+            null_map = &nullable->get_null_map_column().get_data();
+        }
+
+        auto dst_nested_column = ColumnInt64::create();
+        ColumnInt64::Container& dst_values = dst_nested_column->get_data();
+        dst_values.resize(offsets->back());
+
+        if (arguments.size() == 1) {
+            DataTypePtr src_column_type = block.get_by_position(arguments[0]).type;
+            if (src_column_type->is_nullable()) {
+                src_column_type =
+                        assert_cast<const DataTypeNullable&>(*src_column_type).get_nested_type();
+            }
+            auto nested_type =
+                    assert_cast<const DataTypeArray&>(*src_column_type).get_nested_type();
+            WhichDataType which(remove_nullable(nested_type));
+            if (which.is_uint8()) {
+                _execute_number<ColumnUInt8>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int8()) {
+                _execute_number<ColumnInt8>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int16()) {
+                _execute_number<ColumnInt16>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int32()) {
+                _execute_number<ColumnInt32>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int64()) {
+                _execute_number<ColumnInt64>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_int128()) {
+                _execute_number<ColumnInt128>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_float32()) {
+                _execute_number<ColumnFloat32>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_float64()) {
+                _execute_number<ColumnFloat64>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date()) {
+                _execute_number<ColumnDate>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_time()) {
+                _execute_number<ColumnDateTime>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_v2()) {
+                _execute_number<ColumnDateV2>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_date_time_v2()) {
+                _execute_number<ColumnDateTimeV2>(data_columns, *offsets, null_map, dst_values);
+            } else if (which.is_decimal128()) {

Review Comment:
   all right.



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1461265566

   PR approved by anyone and no changes requested.


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] bobhan1 commented on pull request #17541: [feature](array function) add support for array_enumerate_uniq

Posted by "bobhan1 (via GitHub)" <gi...@apache.org>.
bobhan1 commented on PR #17541:
URL: https://github.com/apache/doris/pull/17541#issuecomment-1458277379

   @eldenmoon 


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org