You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "wzymumon (via GitHub)" <gi...@apache.org> on 2023/04/11 08:47:57 UTC

[GitHub] [doris] wzymumon opened a new pull request, #18557: [feature](array function) support array_count function (#17313)

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

   # Proposed changes
   
   Issue Number: close #17313 
   
   ## Problem summary
   
   support array_count function.
   array_count:Returns the number of non-zero and non-null elements in the given array.
   
   ```
   mysql> select array_count([]);
   +----------------------+
   | array_count(ARRAY()) |
   +----------------------+
   |                    0 |
   +----------------------+
   1 row in set (0.02 sec)
   
   mysql> select array_count([0,0,1,2,4,8,16,32]);
   +----------------------------------------------+
   | array_count(ARRAY(0, 0, 1, 2, 4, 8, 16, 32)) |
   +----------------------------------------------+
   |                                            6 |
   +----------------------------------------------+
   1 row in set (0.01 sec)
   
   mysql> select array_count([0,0,0,0]);
   +--------------------------------+
   | array_count(ARRAY(0, 0, 0, 0)) |
   +--------------------------------+
   |                              0 |
   +--------------------------------+
   1 row in set (0.01 sec)
   
   mysql> select array_count([null, null, null]); 
   +--------------------------------------+
   | array_count(ARRAY(NULL, NULL, NULL)) |
   +--------------------------------------+
   |                                    0 |
   +--------------------------------------+
   1 row in set (0.00 sec)
   
   mysql> select array_count(NULL);
   +-------------------+
   | array_count(NULL) |
   +-------------------+
   |              NULL |
   +-------------------+
   1 row in set (0.01 sec)
   ```
   
   ## Checklist(Required)
   
   * [x] Does it affect the original behavior
   * [x] Has unit tests been added
   * [x] 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] eldenmoon commented on a diff in pull request #18557: [feature](function) support array_count function

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


##########
docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_count.md:
##########
@@ -0,0 +1,86 @@
+---
+{
+    "title": "array_count",
+    "language": "zh-CN"
+}
+---
+
+<!--
+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_count
+
+<version since="1.2.0">

Review Comment:
   change version to 1.2.4



##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,154 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> 3

Review Comment:
   we should support lambda function for the first argument



-- 
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 #18557: [vectorized](function) support array_count function

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

   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] wzymumon commented on a diff in pull request #18557: [feature](function) support array_count function

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


##########
docs/en/docs/sql-manual/sql-functions/array-functions/array_count.md:
##########
@@ -0,0 +1,95 @@
+---

Review Comment:
   done



##########
docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_count.md:
##########
@@ -0,0 +1,86 @@
+---
+{
+    "title": "array_count",
+    "language": "zh-CN"
+}
+---
+
+<!--
+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_count
+
+<version since="1.2.0">

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-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] zclllyybb commented on a diff in pull request #18557: [feature](function) support array_count function

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


##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,154 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> 3
+class FunctionArrayCount : public IFunction {
+public:
+    static constexpr auto name = "array_count";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayCount>(); }
+
+    /// Get function name.
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return false; }
+
+    size_t get_number_of_arguments() const override { return 1; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
+        DCHECK(is_array(arguments[0]))
+                << "first argument for function: " << name << " should be DataTypeArray";
+        return make_nullable(std::make_shared<DataTypeInt64>());
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        // extract array offsets and nested data
+        auto left_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();

Review Comment:
   Please dont use `convert_to_full_column_if_const`. Nowadays our common usage is listed in [document](https://selectdb.feishu.cn/docx/UtysdxKDkoJ5xoxtJEUcoN6ineU) 



-- 
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] zhangstar333 commented on pull request #18557: [feature](function) support array_count function

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

   could you add one row like: [0,1,2,3,null] for test


-- 
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] wzymumon commented on pull request #18557: [vectorized](function) support array_count function

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

   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] wzymumon commented on pull request #18557: [vectorized](function) support array_count function

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

   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] wzymumon commented on a diff in pull request #18557: [vectorized](function) support array_count function

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


##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,93 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> [3]
+class FunctionArrayCount : public IFunction {
+public:
+    static constexpr auto name = "array_count";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayCount>(); }
+
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return false; }
+
+    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 {
+        return std::make_shared<DataTypeInt64>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        auto src_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+                
+        const ColumnArray* array_column = nullptr;
+        const UInt8* array_null_map = nullptr;
+        if (src_column->is_nullable()) {
+            auto nullable_array = assert_cast<const ColumnNullable*>(src_column.get());
+            array_column = assert_cast<const ColumnArray*>(&nullable_array->get_nested_column());
+            array_null_map = nullable_array->get_null_map_column().get_data().data();
+        } else {
+            array_column = assert_cast<const ColumnArray*>(src_column.get());
+        }
+
+        auto& src_nested_data = array_column->get_data();
+        auto& src_offset = array_column->get_offsets();
+
+        auto result_data_col = ColumnInt64::create(input_rows_count, 0);
+        auto& result_data = result_data_col->get_data();
+        
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            if (array_null_map && array_null_map[i]) {
+                continue;
+            }
+            
+            // default count is 0 if no-zero elment is not found
+            Int64 count = 0;
+            for (size_t off = src_offset[i - 1]; off < src_offset[i]; ++off) {
+                if (!src_nested_data.is_null_at(off) && src_nested_data.get_bool(off)) {
+                    ++count;

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-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 #18557: [vectorized](function) support array_count function

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

   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] github-actions[bot] commented on pull request #18557: [vectorized](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [vectorized](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [feature](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [feature](array function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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] wzymumon commented on a diff in pull request #18557: [vectorized](function) support array_count function

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


##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,93 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> [3]

Review Comment:
   how about this? `array_count(x->x, [0, 1, 1, 1, 0]) -> [3]`



-- 
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 #18557: [vectorized](function) support array_count function

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

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 34.08 seconds
    stream load tsv:          423 seconds loaded 74807831229 Bytes, about 168 MB/s
    stream load json:         22 seconds loaded 2358488459 Bytes, about 102 MB/s
    stream load orc:          59 seconds loaded 1101869774 Bytes, about 17 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/20230508042353_clickbench_pr_139968.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] github-actions[bot] commented on pull request #18557: [vectorized](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [vectorized](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [vectorized](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [feature](array function) support array_count function (#17313)

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [vectorized](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [feature](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [vectorized](function) support array_count function

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


##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,93 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> [3]

Review Comment:
   the comment should be changed



##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,93 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> [3]
+class FunctionArrayCount : public IFunction {
+public:
+    static constexpr auto name = "array_count";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayCount>(); }
+
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return false; }
+
+    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 {
+        return std::make_shared<DataTypeInt64>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        auto src_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+                
+        const ColumnArray* array_column = nullptr;
+        const UInt8* array_null_map = nullptr;
+        if (src_column->is_nullable()) {
+            auto nullable_array = assert_cast<const ColumnNullable*>(src_column.get());
+            array_column = assert_cast<const ColumnArray*>(&nullable_array->get_nested_column());
+            array_null_map = nullable_array->get_null_map_column().get_data().data();
+        } else {
+            array_column = assert_cast<const ColumnArray*>(src_column.get());
+        }
+
+        auto& src_nested_data = array_column->get_data();
+        auto& src_offset = array_column->get_offsets();
+
+        auto result_data_col = ColumnInt64::create(input_rows_count, 0);
+        auto& result_data = result_data_col->get_data();
+        
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            if (array_null_map && array_null_map[i]) {
+                continue;
+            }
+            
+            // default count is 0 if no-zero elment is not found
+            Int64 count = 0;
+            for (size_t off = src_offset[i - 1]; off < src_offset[i]; ++off) {
+                if (!src_nested_data.is_null_at(off) && src_nested_data.get_bool(off)) {
+                    ++count;

Review Comment:
   get_bool will call virtual function, and lead to performance issue, we should modify not call virtual function



##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,93 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> [3]
+class FunctionArrayCount : public IFunction {
+public:
+    static constexpr auto name = "array_count";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayCount>(); }
+
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return false; }
+
+    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 {
+        return std::make_shared<DataTypeInt64>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        auto src_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+                
+        const ColumnArray* array_column = nullptr;
+        const UInt8* array_null_map = nullptr;
+        if (src_column->is_nullable()) {
+            auto nullable_array = assert_cast<const ColumnNullable*>(src_column.get());
+            array_column = assert_cast<const ColumnArray*>(&nullable_array->get_nested_column());
+            array_null_map = nullable_array->get_null_map_column().get_data().data();
+        } else {
+            array_column = assert_cast<const ColumnArray*>(src_column.get());
+        }
+
+        auto& src_nested_data = array_column->get_data();
+        auto& src_offset = array_column->get_offsets();
+
+        auto result_data_col = ColumnInt64::create(input_rows_count, 0);
+        auto& result_data = result_data_col->get_data();
+        
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            if (array_null_map && array_null_map[i]) {
+                continue;
+            }
+            
+            // default count is 0 if no-zero elment is not found

Review Comment:
   this comment should alse be modified



##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,154 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> 3
+class FunctionArrayCount : public IFunction {
+public:
+    static constexpr auto name = "array_count";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayCount>(); }
+
+    /// Get function name.
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return false; }
+
+    size_t get_number_of_arguments() const override { return 1; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
+        DCHECK(is_array(arguments[0]))
+                << "first argument for function: " << name << " should be DataTypeArray";
+        return make_nullable(std::make_shared<DataTypeInt64>());
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        // extract array offsets and nested data
+        auto left_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();

Review Comment:
   remind



##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,93 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> [3]
+class FunctionArrayCount : public IFunction {
+public:
+    static constexpr auto name = "array_count";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayCount>(); }
+
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return false; }
+
+    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 {
+        return std::make_shared<DataTypeInt64>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        auto src_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+                
+        const ColumnArray* array_column = nullptr;
+        const UInt8* array_null_map = nullptr;
+        if (src_column->is_nullable()) {
+            auto nullable_array = assert_cast<const ColumnNullable*>(src_column.get());
+            array_column = assert_cast<const ColumnArray*>(&nullable_array->get_nested_column());
+            array_null_map = nullable_array->get_null_map_column().get_data().data();
+        } else {
+            array_column = assert_cast<const ColumnArray*>(src_column.get());
+        }
+
+        auto& src_nested_data = array_column->get_data();
+        auto& src_offset = array_column->get_offsets();
+
+        auto result_data_col = ColumnInt64::create(input_rows_count, 0);
+        auto& result_data = result_data_col->get_data();
+        
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            if (array_null_map && array_null_map[i]) {
+                continue;
+            }
+            
+            // default count is 0 if no-zero elment is not found
+            Int64 count = 0;
+            for (size_t off = src_offset[i - 1]; off < src_offset[i]; ++off) {
+                if (!src_nested_data.is_null_at(off) && src_nested_data.get_bool(off)) {
+                    ++count;

Review Comment:
   same as is_null_at



##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,93 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> [3]
+class FunctionArrayCount : public IFunction {
+public:
+    static constexpr auto name = "array_count";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayCount>(); }
+
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return false; }
+
+    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 {
+        return std::make_shared<DataTypeInt64>();
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        auto src_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+                
+        const ColumnArray* array_column = nullptr;
+        const UInt8* array_null_map = nullptr;
+        if (src_column->is_nullable()) {
+            auto nullable_array = assert_cast<const ColumnNullable*>(src_column.get());
+            array_column = assert_cast<const ColumnArray*>(&nullable_array->get_nested_column());
+            array_null_map = nullable_array->get_null_map_column().get_data().data();
+        } else {
+            array_column = assert_cast<const ColumnArray*>(src_column.get());
+        }
+
+        auto& src_nested_data = array_column->get_data();
+        auto& src_offset = array_column->get_offsets();
+
+        auto result_data_col = ColumnInt64::create(input_rows_count, 0);
+        auto& result_data = result_data_col->get_data();
+        
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            if (array_null_map && array_null_map[i]) {
+                continue;
+            }
+            
+            // default count is 0 if no-zero elment is not found
+            Int64 count = 0;
+            for (size_t off = src_offset[i - 1]; off < src_offset[i]; ++off) {
+                if (!src_nested_data.is_null_at(off) && src_nested_data.get_bool(off)) {
+                    ++count;

Review Comment:
   we could do some cast here



-- 
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 #18557: [feature](function) support array_count function

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


##########
docs/en/docs/sql-manual/sql-functions/array-functions/array_count.md:
##########
@@ -0,0 +1,95 @@
+---

Review Comment:
   add sidebar to docs



-- 
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] wzymumon commented on pull request #18557: [feature](function) support array_count function

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

   > could you add one row like: [0,1,2,3,null] for test
   
   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-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] wzymumon commented on a diff in pull request #18557: [feature](function) support array_count function

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


##########
be/src/vec/functions/array/function_array_count.cpp:
##########
@@ -0,0 +1,154 @@
+// 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/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 {
+
+// array_count([1, 2, 3, 0, 0]) -> 3
+class FunctionArrayCount : public IFunction {
+public:
+    static constexpr auto name = "array_count";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayCount>(); }
+
+    /// Get function name.
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return false; }
+
+    size_t get_number_of_arguments() const override { return 1; }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
+        DCHECK(is_array(arguments[0]))
+                << "first argument for function: " << name << " should be DataTypeArray";
+        return make_nullable(std::make_shared<DataTypeInt64>());
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        // extract array offsets and nested data
+        auto left_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();

Review Comment:
   > Please dont use `convert_to_full_column_if_const`. Nowadays our common usage is listed in [document](https://selectdb.feishu.cn/docx/UtysdxKDkoJ5xoxtJEUcoN6ineU)
   
   ok. I will fix it later



-- 
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 #18557: [vectorized](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [vectorized](function) support array_count function

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

   PR approved by at least one committer 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] qidaye merged pull request #18557: [vectorized](function) support array_count function

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


-- 
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 #18557: [feature](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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 #18557: [vectorized](function) support array_count function

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

   clang-tidy review says "All clean, LGTM! :+1:"


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