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

[GitHub] [doris] ZashJie opened a new pull request, #19239: [feature](array_function) add support for array_reduce

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

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## 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] carlvinhust2012 commented on a diff in pull request #19239: [feature](array_function) add support for array_reduce

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


##########
be/CMakeLists.txt:
##########
@@ -87,7 +87,7 @@ message(STATUS "USE_JEMALLOC is ${USE_JEMALLOC}")
 
 # set CMAKE_BUILD_TYPE
 if (NOT CMAKE_BUILD_TYPE)
-    set(CMAKE_BUILD_TYPE RELEASE)
+    set(CMAKE_BUILD_TYPE ASAN)

Review Comment:
   why do you change this option? 



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


Re: [PR] [feature](array_function) add support for array_reduce [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #19239: [feature](array_function) add support for array_reduce
URL: https://github.com/apache/doris/pull/19239


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


Re: [PR] [feature](array_function) add support for array_reduce [doris]

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

   We're closing this PR because it hasn't been updated in a while.
   This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and feel free a maintainer to remove the Stale tag!


-- 
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 #19239: [feature](array_function) add support for array_reduce

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

   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] ZashJie commented on a diff in pull request #19239: [feature](array_function) add support for array_reduce

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


##########
be/src/vec/functions/array/function_array_reduce.cpp:
##########
@@ -0,0 +1,206 @@
+// 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>
+#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
+#include "vec/common/arena.h"
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "olap/tablet_schema.h"
+
+
+namespace doris {
+class FunctionContext;
+} // namespace doris
+
+namespace doris::vectorized {
+
+class Arena;
+
+// array_reduce("sum", [1,2,3,4]) -> 10
+class FunctionArrayReduce : public IFunction {
+public:
+    static constexpr auto name = "array_reduce";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayReduce>(); }
+
+    String get_name() const override { return name; }
+
+    size_t get_number_of_arguments() const override { return 2; }
+    ColumnNumbers get_arguments_that_are_always_constant() const override { return {1, 2}; }
+
+    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName & arguments) const override {
+        DataTypes argument_types(arguments.size() - 1);
+        const DataTypeArray * arg = check_and_get_data_type<DataTypeArray>(arguments[1].type.get());
+        argument_types[0] = arg->get_nested_type();
+
+        columnWithTypeAndName = arguments[1];
+        
+
+        if (!aggregate_function)
+        {
+            aggregate_function = vectorized::AggregateFunctionSimpleFactory::instance().get(
+                    "sum", argument_types);
+        }
+
+        std::cout << "YEAH" << std::endl;
+        
+        return arguments[1].type;
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        // 获取函数名                        
+        const ColumnConst& rhs_value_column =
+                static_cast<const ColumnConst&>(*block.get_by_position(arguments[0]).column.get());
+
+        // String aggregate_function_name_with_params = rhs_value_column.get_value<String>();
+        // std::cout << aggregate_function_name_with_params << std::endl;
+
+        ColumnPtr haystack_ptr = block.get_by_position(arguments[0]).column;
+
+        const ColumnConst* col_haystack_const =
+                check_and_get_column_const<ColumnString>(&*haystack_ptr);
+
+        // String aggregate_function_name_with_param = col_haystack_const->get_value<String>();
+        
+        // std::cout << aggregate_function_name_with_param << std::endl;
+
+        // AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
+        // auto agg_function = factory.get(aggregate_function_name_with_params, {block.get_data_type(1)});
+
+        std::cout << "----" << std::endl;
+        // const IAggregateFunction & agg_func = *agg_function;
+        
+        const size_t num_arguments_columns = arguments.size() - 1;
+
+        std::vector<const IColumn *> aggregate_arguments_vec(num_arguments_columns);
+
+        std::cout << "----" << std::endl;
+        // for (size_t i = 0; i < num_arguments_columns; ++i) {
+            // ->convert_to_full_column_if_const();
+        // const IColumn * col = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+        const auto& col = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+        
+        if (const ColumnArray * arr = check_and_get_column<ColumnArray>(*col)) {
+            aggregate_arguments_vec[0] = &arr->get_data();
+            std::cout << "YEAH" << std::endl;
+            const auto& name = arr->get_name();
+            std::cout << &name << std::endl;
+            std::cout << "----" << std::endl;
+            // offsets_i = &arr->get_offsets();
+        }
+        else {
+            std::cout << "---------ERROR----------" << std::endl;
+        }
+
+        // if (i == 0)

Review Comment:
   I'm sorry, I submitted a PR to have someone look at my code, so there's a lot of problematic code in there.



-- 
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] carlvinhust2012 commented on a diff in pull request #19239: [feature](array_function) add support for array_reduce

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


##########
be/src/vec/functions/array/function_array_reduce.cpp:
##########
@@ -0,0 +1,206 @@
+// 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>
+#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
+#include "vec/common/arena.h"
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "olap/tablet_schema.h"
+
+
+namespace doris {
+class FunctionContext;
+} // namespace doris
+
+namespace doris::vectorized {
+
+class Arena;
+
+// array_reduce("sum", [1,2,3,4]) -> 10
+class FunctionArrayReduce : public IFunction {
+public:
+    static constexpr auto name = "array_reduce";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayReduce>(); }
+
+    String get_name() const override { return name; }
+
+    size_t get_number_of_arguments() const override { return 2; }
+    ColumnNumbers get_arguments_that_are_always_constant() const override { return {1, 2}; }
+
+    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName & arguments) const override {
+        DataTypes argument_types(arguments.size() - 1);
+        const DataTypeArray * arg = check_and_get_data_type<DataTypeArray>(arguments[1].type.get());
+        argument_types[0] = arg->get_nested_type();
+
+        columnWithTypeAndName = arguments[1];
+        
+
+        if (!aggregate_function)
+        {
+            aggregate_function = vectorized::AggregateFunctionSimpleFactory::instance().get(
+                    "sum", argument_types);
+        }
+
+        std::cout << "YEAH" << std::endl;
+        
+        return arguments[1].type;
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        // 获取函数名                        
+        const ColumnConst& rhs_value_column =
+                static_cast<const ColumnConst&>(*block.get_by_position(arguments[0]).column.get());
+
+        // String aggregate_function_name_with_params = rhs_value_column.get_value<String>();

Review Comment:
   why not delete the debug code?



-- 
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] carlvinhust2012 commented on a diff in pull request #19239: [feature](array_function) add support for array_reduce

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


##########
regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy:
##########
@@ -418,6 +418,21 @@ class Suite implements GroovyInterceptable {
         Assert.assertEquals("SUCCESS", status)
     }
 
+    void waitForS3LoadFinished(String label) {
+        // check load state
+        while (true) {
+            def stateResult = sql "show load where Label = '${label}'"
+            logger.info("load result is ${stateResult}")
+            def loadState = stateResult[stateResult.size() - 1][2].toString()
+            if ("CANCELLED".equalsIgnoreCase(loadState)) {
+                throw new IllegalStateException("load ${label} failed.")
+            } else if ("FINISHED".equalsIgnoreCase(loadState)) {
+                break
+            }
+            sleep(5000)

Review Comment:
   sleep(5000) is not alway guarantee that the load is successful,may be check the return status and retry is more better.



-- 
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 #19239: [feature](array_function) add support for array_reduce

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

   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 #19239: [feature](array_function) add support for array_reduce

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

   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 #19239: [feature](array_function) add support for array_reduce

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

   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 #19239: [feature](array_function) add support for array_reduce

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

   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] carlvinhust2012 commented on a diff in pull request #19239: [feature](array_function) add support for array_reduce

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


##########
be/src/vec/functions/array/function_array_reduce.cpp:
##########
@@ -0,0 +1,206 @@
+// 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>
+#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
+#include "vec/common/arena.h"
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "olap/tablet_schema.h"
+
+
+namespace doris {
+class FunctionContext;
+} // namespace doris
+
+namespace doris::vectorized {
+
+class Arena;
+
+// array_reduce("sum", [1,2,3,4]) -> 10
+class FunctionArrayReduce : public IFunction {
+public:
+    static constexpr auto name = "array_reduce";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayReduce>(); }
+
+    String get_name() const override { return name; }
+
+    size_t get_number_of_arguments() const override { return 2; }
+    ColumnNumbers get_arguments_that_are_always_constant() const override { return {1, 2}; }
+
+    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName & arguments) const override {
+        DataTypes argument_types(arguments.size() - 1);
+        const DataTypeArray * arg = check_and_get_data_type<DataTypeArray>(arguments[1].type.get());
+        argument_types[0] = arg->get_nested_type();
+
+        columnWithTypeAndName = arguments[1];
+        
+
+        if (!aggregate_function)
+        {
+            aggregate_function = vectorized::AggregateFunctionSimpleFactory::instance().get(
+                    "sum", argument_types);
+        }
+
+        std::cout << "YEAH" << std::endl;
+        
+        return arguments[1].type;
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        // 获取函数名                        
+        const ColumnConst& rhs_value_column =
+                static_cast<const ColumnConst&>(*block.get_by_position(arguments[0]).column.get());
+
+        // String aggregate_function_name_with_params = rhs_value_column.get_value<String>();
+        // std::cout << aggregate_function_name_with_params << std::endl;
+
+        ColumnPtr haystack_ptr = block.get_by_position(arguments[0]).column;
+
+        const ColumnConst* col_haystack_const =
+                check_and_get_column_const<ColumnString>(&*haystack_ptr);
+
+        // String aggregate_function_name_with_param = col_haystack_const->get_value<String>();
+        
+        // std::cout << aggregate_function_name_with_param << std::endl;
+
+        // AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
+        // auto agg_function = factory.get(aggregate_function_name_with_params, {block.get_data_type(1)});
+
+        std::cout << "----" << std::endl;
+        // const IAggregateFunction & agg_func = *agg_function;
+        
+        const size_t num_arguments_columns = arguments.size() - 1;
+
+        std::vector<const IColumn *> aggregate_arguments_vec(num_arguments_columns);
+
+        std::cout << "----" << std::endl;
+        // for (size_t i = 0; i < num_arguments_columns; ++i) {
+            // ->convert_to_full_column_if_const();
+        // const IColumn * col = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+        const auto& col = block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
+        
+        if (const ColumnArray * arr = check_and_get_column<ColumnArray>(*col)) {
+            aggregate_arguments_vec[0] = &arr->get_data();
+            std::cout << "YEAH" << std::endl;
+            const auto& name = arr->get_name();
+            std::cout << &name << std::endl;
+            std::cout << "----" << std::endl;
+            // offsets_i = &arr->get_offsets();
+        }
+        else {
+            std::cout << "---------ERROR----------" << std::endl;
+        }
+
+        // if (i == 0)

Review Comment:
   why not delete?



-- 
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] carlvinhust2012 commented on a diff in pull request #19239: [feature](array_function) add support for array_reduce

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


##########
be/src/vec/functions/array/function_array_reduce.cpp:
##########
@@ -0,0 +1,206 @@
+// 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>
+#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
+#include "vec/common/arena.h"
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "olap/tablet_schema.h"
+
+
+namespace doris {
+class FunctionContext;
+} // namespace doris
+
+namespace doris::vectorized {
+
+class Arena;
+
+// array_reduce("sum", [1,2,3,4]) -> 10
+class FunctionArrayReduce : public IFunction {
+public:
+    static constexpr auto name = "array_reduce";
+
+    static FunctionPtr create() { return std::make_shared<FunctionArrayReduce>(); }
+
+    String get_name() const override { return name; }
+
+    size_t get_number_of_arguments() const override { return 2; }
+    ColumnNumbers get_arguments_that_are_always_constant() const override { return {1, 2}; }
+
+    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName & arguments) const override {
+        DataTypes argument_types(arguments.size() - 1);
+        const DataTypeArray * arg = check_and_get_data_type<DataTypeArray>(arguments[1].type.get());
+        argument_types[0] = arg->get_nested_type();
+
+        columnWithTypeAndName = arguments[1];
+        
+
+        if (!aggregate_function)
+        {
+            aggregate_function = vectorized::AggregateFunctionSimpleFactory::instance().get(
+                    "sum", argument_types);
+        }
+
+        std::cout << "YEAH" << std::endl;
+        
+        return arguments[1].type;
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        // 获取函数名                        

Review Comment:
   Use English is more better.



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