You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/13 16:45:37 UTC

[GitHub] [incubator-doris] adonis0147 opened a new pull request, #10108: [feature-wip](array-type) Add array aggregation functions

adonis0147 opened a new pull request, #10108:
URL: https://github.com/apache/incubator-doris/pull/10108

   # Proposed changes
   
   Issue Number: close #9055 
   
   ## Problem Summary:
   
   Please refer to #9055 
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: No
   2. Has unit tests been added: Yes
   3. Has document been added or modified: No
   4. Does it need to update dependencies: No
   5. Are there any changes that cannot be rolled back: No
   
   ## 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] [incubator-doris] github-actions[bot] commented on pull request #10108: [feature-wip](array-type) Add array aggregation functions

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #10108:
URL: https://github.com/apache/incubator-doris/pull/10108#issuecomment-1157185607

   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] [incubator-doris] github-actions[bot] commented on pull request #10108: [feature-wip](array-type) Add array aggregation functions

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #10108:
URL: https://github.com/apache/incubator-doris/pull/10108#issuecomment-1157185622

   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] [incubator-doris] carlvinhust2012 commented on a diff in pull request #10108: [feature-wip](array-type) Add array aggregation functions

Posted by GitBox <gi...@apache.org>.
carlvinhust2012 commented on code in PR #10108:
URL: https://github.com/apache/incubator-doris/pull/10108#discussion_r896333301


##########
be/src/vec/aggregate_functions/aggregate_function_product.h:
##########
@@ -0,0 +1,121 @@
+// 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.
+
+#pragma once
+
+#include <cstddef>
+#include <type_traits>
+
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "vec/columns/column_decimal.h"
+#include "vec/columns/column_vector.h"
+#include "vec/common/arena.h"
+#include "vec/common/string_buffer.hpp"
+#include "vec/core/types.h"
+#include "vec/data_types/data_type_decimal.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/io/io_helper.h"
+
+namespace doris {
+namespace vectorized {
+
+template <typename T>
+struct AggregateFunctionProductData {
+    T product {};
+
+    void add(T value) { product *= value; }
+
+    void merge(const AggregateFunctionProductData& other) { product *= other.product; }
+
+    void write(BufferWritable& buffer) const { write_binary(product, buffer); }
+
+    void read(BufferReadable& buffer) { read_binary(product, buffer); }
+
+    T get() const { return product; }
+
+    void reset(T value) { product = std::move(value); }
+};
+
+template <typename T, typename TResult, typename Data>
+class AggregateFunctionProduct final
+        : public IAggregateFunctionDataHelper<Data, AggregateFunctionProduct<T, TResult, Data>> {
+public:
+    using ResultDataType = std::conditional_t<IsDecimalNumber<T>, DataTypeDecimal<TResult>,
+                                              DataTypeNumber<TResult>>;
+    using ColVecType = std::conditional_t<IsDecimalNumber<T>, ColumnDecimal<T>, ColumnVector<T>>;
+    using ColVecResult =
+            std::conditional_t<IsDecimalNumber<T>, ColumnDecimal<TResult>, ColumnVector<TResult>>;
+
+    std::string get_name() const { return "product"; }
+
+    AggregateFunctionProduct(const DataTypes& argument_types_)
+            : IAggregateFunctionDataHelper<Data, AggregateFunctionProduct<T, TResult, Data>>(
+                      argument_types_, {}),
+              scale(0) {}
+
+    AggregateFunctionProduct(const IDataType& data_type, const DataTypes& argument_types_)
+            : IAggregateFunctionDataHelper<Data, AggregateFunctionProduct<T, TResult, Data>>(
+                      argument_types_, {}),
+              scale(get_decimal_scale(data_type)) {}
+
+    DataTypePtr get_return_type() const override {
+        if constexpr (IsDecimalNumber<T>) {
+            return std::make_shared<ResultDataType>(ResultDataType::max_precision(), scale);
+        } else {
+            return std::make_shared<ResultDataType>();
+        }
+    }
+
+    void add(AggregateDataPtr __restrict place, const IColumn** columns, size_t row_num,
+             Arena*) const override {
+        const auto& column = static_cast<const ColVecType&>(*columns[0]);
+        this->data(place).add(column.get_data()[row_num]);
+    };

Review Comment:
   why does this line add ";" ?



-- 
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] [incubator-doris] adonis0147 commented on a diff in pull request #10108: [feature-wip](array-type) Add array aggregation functions

Posted by GitBox <gi...@apache.org>.
adonis0147 commented on code in PR #10108:
URL: https://github.com/apache/incubator-doris/pull/10108#discussion_r896337225


##########
be/src/vec/aggregate_functions/aggregate_function_product.h:
##########
@@ -0,0 +1,121 @@
+// 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.
+
+#pragma once
+
+#include <cstddef>
+#include <type_traits>
+
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "vec/columns/column_decimal.h"
+#include "vec/columns/column_vector.h"
+#include "vec/common/arena.h"
+#include "vec/common/string_buffer.hpp"
+#include "vec/core/types.h"
+#include "vec/data_types/data_type_decimal.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/io/io_helper.h"
+
+namespace doris {
+namespace vectorized {
+
+template <typename T>
+struct AggregateFunctionProductData {
+    T product {};
+
+    void add(T value) { product *= value; }
+
+    void merge(const AggregateFunctionProductData& other) { product *= other.product; }
+
+    void write(BufferWritable& buffer) const { write_binary(product, buffer); }
+
+    void read(BufferReadable& buffer) { read_binary(product, buffer); }
+
+    T get() const { return product; }
+
+    void reset(T value) { product = std::move(value); }
+};
+
+template <typename T, typename TResult, typename Data>
+class AggregateFunctionProduct final
+        : public IAggregateFunctionDataHelper<Data, AggregateFunctionProduct<T, TResult, Data>> {
+public:
+    using ResultDataType = std::conditional_t<IsDecimalNumber<T>, DataTypeDecimal<TResult>,
+                                              DataTypeNumber<TResult>>;
+    using ColVecType = std::conditional_t<IsDecimalNumber<T>, ColumnDecimal<T>, ColumnVector<T>>;
+    using ColVecResult =
+            std::conditional_t<IsDecimalNumber<T>, ColumnDecimal<TResult>, ColumnVector<TResult>>;
+
+    std::string get_name() const { return "product"; }
+
+    AggregateFunctionProduct(const DataTypes& argument_types_)
+            : IAggregateFunctionDataHelper<Data, AggregateFunctionProduct<T, TResult, Data>>(
+                      argument_types_, {}),
+              scale(0) {}
+
+    AggregateFunctionProduct(const IDataType& data_type, const DataTypes& argument_types_)
+            : IAggregateFunctionDataHelper<Data, AggregateFunctionProduct<T, TResult, Data>>(
+                      argument_types_, {}),
+              scale(get_decimal_scale(data_type)) {}
+
+    DataTypePtr get_return_type() const override {
+        if constexpr (IsDecimalNumber<T>) {
+            return std::make_shared<ResultDataType>(ResultDataType::max_precision(), scale);
+        } else {
+            return std::make_shared<ResultDataType>();
+        }
+    }
+
+    void add(AggregateDataPtr __restrict place, const IColumn** columns, size_t row_num,
+             Arena*) const override {
+        const auto& column = static_cast<const ColVecType&>(*columns[0]);
+        this->data(place).add(column.get_data()[row_num]);
+    };

Review Comment:
   Typos, fixed.



-- 
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] [incubator-doris] HappenLee merged pull request #10108: [feature-wip](array-type) Add array aggregation functions

Posted by GitBox <gi...@apache.org>.
HappenLee merged PR #10108:
URL: https://github.com/apache/incubator-doris/pull/10108


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