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/10/25 07:18:00 UTC

[GitHub] [doris] eldenmoon opened a new pull request, #13641: [feature-array](array-type) Add array function array_popback

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

   Remove the last element from array.
   
   ```
   mysql> select array_popback(['test', NULL, 'value']);
   +-----------------------------------------------------+
   | array_popback(ARRAY('test', NULL, 'value')) |
   +-----------------------------------------------------+
   | [test, NULL]                                        |
   +-----------------------------------------------------+
   ```
   
   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] 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] [doris] hello-stephen commented on pull request #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #13641:
URL: https://github.com/apache/doris/pull/13641#issuecomment-1294805855

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 38.39 seconds
    load time: 560 seconds
    storage size: 17154699395 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221028100733_clickbench_pr_35310.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] eldenmoon commented on pull request #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
eldenmoon commented on PR #13641:
URL: https://github.com/apache/doris/pull/13641#issuecomment-1296463227

   rebased


-- 
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 #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
eldenmoon commented on code in PR #13641:
URL: https://github.com/apache/doris/pull/13641#discussion_r1007568633


##########
be/src/vec/functions/array/function_array_popback.cpp:
##########
@@ -0,0 +1,85 @@
+// 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 <string_view>
+
+#include "vec/columns/column_array.h"
+#include "vec/columns/column_string.h"
+#include "vec/common/string_ref.h"
+#include "vec/data_types/data_type_array.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/functions/array/function_array_utils.h"
+#include "vec/functions/function.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized {
+
+class FunctionArrayPopback : public IFunction {
+public:
+    static constexpr auto name = "array_popback";
+    static FunctionPtr create() { return std::make_shared<FunctionArrayPopback>(); }
+
+    /// Get function name.
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return true; }
+
+    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 but it has type " << arguments[0]->get_name() << ".";
+        return arguments[0];
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        auto array_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+        // extract src array column
+        ColumnArrayExecutionData src;
+        if (!extract_column_array_info(*array_column, src)) {
+            return Status::RuntimeError(
+                    fmt::format("execute failed, unsupported types for function {}({}, {})",
+                                get_name(), block.get_by_position(arguments[0]).type->get_name(),
+                                block.get_by_position(arguments[1]).type->get_name()));

Review Comment:
   thanks for your careful review, I'll modify for your comments



-- 
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 #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #13641:
URL: https://github.com/apache/doris/pull/13641#issuecomment-1294513203

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 39.59 seconds
    load time: 574 seconds
    storage size: 17154699384 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221028061759_clickbench_pr_35185.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 #13641: [feature-array](array-type) Add array function array_popback

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

   PR approved by anyone and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] xy720 commented on a diff in pull request #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
xy720 commented on code in PR #13641:
URL: https://github.com/apache/doris/pull/13641#discussion_r1006961817


##########
be/src/vec/functions/array/function_array_popback.cpp:
##########
@@ -0,0 +1,85 @@
+// 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 <string_view>
+
+#include "vec/columns/column_array.h"
+#include "vec/columns/column_string.h"
+#include "vec/common/string_ref.h"
+#include "vec/data_types/data_type_array.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/functions/array/function_array_utils.h"
+#include "vec/functions/function.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized {
+
+class FunctionArrayPopback : public IFunction {
+public:
+    static constexpr auto name = "array_popback";
+    static FunctionPtr create() { return std::make_shared<FunctionArrayPopback>(); }
+
+    /// Get function name.
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return true; }

Review Comment:
   ```suggestion
       bool is_variadic() const override { return false; }
   ```
   
   is_variadic means the argument number of function is non-deterministic.



##########
docs/zh-CN/docs/sql-manual/sql-functions/array-functions/array_popback.md:
##########
@@ -0,0 +1,56 @@
+---
+{
+    "title": "array_popback",
+    "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_popback
+
+### description
+
+#### Syntax
+
+```
+ARRAY<T> array_popback(ARRAY<T> arr)
+```
+
+返回移除最后一个元素后的数组,如果输入参数为NULL,则返回NULL
+
+### notice
+
+`仅支持向量化引擎中使用`
+
+### example
+
+```
+mysql> set enable_vectorized_engine=true;
+
+mysql> select array_popback(['test', NULL, 'value']);
++-----------------------------------------------------+
+| array_popback(ARRAY('test', NULL, 'value'), 'value') |

Review Comment:
   ```suggestion
   | array_popback(ARRAY('test', NULL, 'value')) |
   ```



##########
be/src/vec/functions/array/function_array_popback.cpp:
##########
@@ -0,0 +1,85 @@
+// 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 <string_view>
+
+#include "vec/columns/column_array.h"
+#include "vec/columns/column_string.h"
+#include "vec/common/string_ref.h"
+#include "vec/data_types/data_type_array.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/functions/array/function_array_utils.h"
+#include "vec/functions/function.h"
+#include "vec/functions/simple_function_factory.h"
+
+namespace doris::vectorized {
+
+class FunctionArrayPopback : public IFunction {
+public:
+    static constexpr auto name = "array_popback";
+    static FunctionPtr create() { return std::make_shared<FunctionArrayPopback>(); }
+
+    /// Get function name.
+    String get_name() const override { return name; }
+
+    bool is_variadic() const override { return true; }
+
+    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 but it has type " << arguments[0]->get_name() << ".";
+        return arguments[0];
+    }
+
+    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) override {
+        auto array_column =
+                block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+        // extract src array column
+        ColumnArrayExecutionData src;
+        if (!extract_column_array_info(*array_column, src)) {
+            return Status::RuntimeError(
+                    fmt::format("execute failed, unsupported types for function {}({}, {})",
+                                get_name(), block.get_by_position(arguments[0]).type->get_name(),
+                                block.get_by_position(arguments[1]).type->get_name()));

Review Comment:
   arguments[1] out of limit



-- 
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 #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
eldenmoon commented on PR #13641:
URL: https://github.com/apache/doris/pull/13641#issuecomment-1293513538

   @cambyzju  @xy720  could you plz review this PR ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] hello-stephen commented on pull request #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #13641:
URL: https://github.com/apache/doris/pull/13641#issuecomment-1294530415

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 39.27 seconds
    load time: 634 seconds
    storage size: 17154810780 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221028064028_clickbench_pr_35204.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 #13641: [feature-array](array-type) Add array function array_popback

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

   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] xy720 merged pull request #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
xy720 merged PR #13641:
URL: https://github.com/apache/doris/pull/13641


-- 
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] xy720 commented on pull request #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
xy720 commented on PR #13641:
URL: https://github.com/apache/doris/pull/13641#issuecomment-1301823814

   It seems that P1 regression is failed, please rebase master.


-- 
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 #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
eldenmoon commented on PR #13641:
URL: https://github.com/apache/doris/pull/13641#issuecomment-1301853343

   rebased


-- 
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 #13641: [feature-array](array-type) Add array function array_popback

Posted by GitBox <gi...@apache.org>.
eldenmoon commented on PR #13641:
URL: https://github.com/apache/doris/pull/13641#issuecomment-1302974553

   @xy720 lets merge this PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

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


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