This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new 1f3d0e2fbfd branch-4.1: [enhance](agg) Support max_by/min_by agg 
functions for some complex type #58736 (#63458)
1f3d0e2fbfd is described below

commit 1f3d0e2fbfdba95dd98f721c18991ab5e0ceb54d
Author: zclllyybb <[email protected]>
AuthorDate: Thu May 21 18:19:02 2026 +0800

    branch-4.1: [enhance](agg) Support max_by/min_by agg functions for some 
complex type #58736 (#63458)
    
    pick https://github.com/apache/doris/pull/58736
    
    Co-authored-by: admiring_xm <[email protected]>
---
 .../exprs/aggregate/aggregate_function_max_by.cpp  | 32 -----------
 .../exprs/aggregate/aggregate_function_min_by.cpp  | 32 -----------
 .../aggregate/aggregate_function_min_max_by.cpp    |  6 +-
 .../aggregate/aggregate_function_min_max_by.h      | 28 +++++++--
 .../aggregate/aggregate_function_min_max_impl.h    |  1 +
 .../aggregate_function_simple_factory.cpp          |  6 +-
 be/test/exprs/aggregate/agg_min_max_by_test.cpp    |  6 +-
 .../trees/expressions/functions/agg/MaxBy.java     |  7 ++-
 .../trees/expressions/functions/agg/MinBy.java     |  7 ++-
 .../test_aggregate_all_functions2.out              | 67 +++++++++++++++++++++-
 .../test_aggregate_all_functions2.groovy           | 34 ++++++++---
 11 files changed, 134 insertions(+), 92 deletions(-)

diff --git a/be/src/exprs/aggregate/aggregate_function_max_by.cpp 
b/be/src/exprs/aggregate/aggregate_function_max_by.cpp
deleted file mode 100644
index 3e90ee9fe9c..00000000000
--- a/be/src/exprs/aggregate/aggregate_function_max_by.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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 <memory>
-
-#include "exprs/aggregate/aggregate_function_min_max_by.h"
-#include "exprs/aggregate/aggregate_function_simple_factory.h"
-
-namespace doris {
-#include "common/compile_check_begin.h"
-
-void register_aggregate_function_max_by(AggregateFunctionSimpleFactory& 
factory) {
-    factory.register_function_both(
-            "max_by", 
create_aggregate_function_min_max_by<AggregateFunctionsMinMaxBy,
-                                                           
AggregateFunctionMaxByData>);
-}
-
-} // namespace doris
diff --git a/be/src/exprs/aggregate/aggregate_function_min_by.cpp 
b/be/src/exprs/aggregate/aggregate_function_min_by.cpp
deleted file mode 100644
index b1010c4612d..00000000000
--- a/be/src/exprs/aggregate/aggregate_function_min_by.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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 <memory>
-
-#include "exprs/aggregate/aggregate_function_min_max_by.h"
-#include "exprs/aggregate/aggregate_function_simple_factory.h"
-
-namespace doris {
-#include "common/compile_check_begin.h"
-
-void register_aggregate_function_min_by(AggregateFunctionSimpleFactory& 
factory) {
-    factory.register_function_both(
-            "min_by", 
create_aggregate_function_min_max_by<AggregateFunctionsMinMaxBy,
-                                                           
AggregateFunctionMinByData>);
-}
-
-} // namespace doris
diff --git a/be/src/exprs/aggregate/aggregate_function_min_max_by.cpp 
b/be/src/exprs/aggregate/aggregate_function_min_max_by.cpp
index fd2a6ec6119..7d237018d40 100644
--- a/be/src/exprs/aggregate/aggregate_function_min_max_by.cpp
+++ b/be/src/exprs/aggregate/aggregate_function_min_max_by.cpp
@@ -60,11 +60,9 @@ std::unique_ptr<MaxMinValueBase> create_max_min_value(const 
DataTypePtr& type, i
 
 void register_aggregate_function_max_min_by(AggregateFunctionSimpleFactory& 
factory) {
     factory.register_function_both(
-            "min_by", 
create_aggregate_function_min_max_by<AggregateFunctionsMinMaxBy,
-                                                           
AggregateFunctionMinByData>);
+            "min_by", 
create_aggregate_function_min_max_by<AggregateFunctionMinByData>);
     factory.register_function_both(
-            "max_by", 
create_aggregate_function_min_max_by<AggregateFunctionsMinMaxBy,
-                                                           
AggregateFunctionMaxByData>);
+            "max_by", 
create_aggregate_function_min_max_by<AggregateFunctionMaxByData>);
 }
 
 } // namespace doris
diff --git a/be/src/exprs/aggregate/aggregate_function_min_max_by.h 
b/be/src/exprs/aggregate/aggregate_function_min_max_by.h
index 30fd4b27aec..153d9ce2198 100644
--- a/be/src/exprs/aggregate/aggregate_function_min_max_by.h
+++ b/be/src/exprs/aggregate/aggregate_function_min_max_by.h
@@ -312,7 +312,7 @@ public:
     }
 };
 
-template <template <typename> class AggregateFunctionTemplate, template 
<typename> class Data>
+template <template <typename> class Data>
 AggregateFunctionPtr create_aggregate_function_min_max_by(const String& name,
                                                           const DataTypes& 
argument_types,
                                                           const DataTypePtr& 
result_type,
@@ -328,11 +328,11 @@ AggregateFunctionPtr 
create_aggregate_function_min_max_by(const String& name,
         constexpr auto PT = DispatchType::PType;
         if constexpr (is_decimal(PT)) {
             result = creator_without_type::create_multi_arguments<
-                    
AggregateFunctionTemplate<Data<SingleValueDataDecimal<PT>>>>(
+                    
AggregateFunctionsMinMaxBy<Data<SingleValueDataDecimal<PT>>>>(
                     argument_types, result_is_nullable, attr);
         } else {
             result = creator_without_type::create_multi_arguments<
-                    AggregateFunctionTemplate<Data<SingleValueDataFixed<PT>>>>(
+                    
AggregateFunctionsMinMaxBy<Data<SingleValueDataFixed<PT>>>>(
                     argument_types, result_is_nullable, attr);
         }
         return true;
@@ -346,13 +346,29 @@ AggregateFunctionPtr 
create_aggregate_function_min_max_by(const String& name,
     case PrimitiveType::TYPE_VARCHAR:
     case PrimitiveType::TYPE_STRING:
         return creator_without_type::create_multi_arguments<
-                
AggregateFunctionTemplate<Data<SingleValueDataString>>>(argument_types,
-                                                                        
result_is_nullable, attr);
+                
AggregateFunctionsMinMaxBy<Data<SingleValueDataString>>>(argument_types,
+                                                                         
result_is_nullable, attr);
+    case PrimitiveType::TYPE_DATE:
+        return creator_without_type::create_multi_arguments<
+                
AggregateFunctionsMinMaxBy<Data<SingleValueDataFixed<TYPE_DATE>>>>(
+                argument_types, result_is_nullable, attr);
+    case PrimitiveType::TYPE_DATETIME:
+        return creator_without_type::create_multi_arguments<
+                
AggregateFunctionsMinMaxBy<Data<SingleValueDataFixed<TYPE_DATETIME>>>>(
+                argument_types, result_is_nullable, attr);
+    case PrimitiveType::TYPE_DATEV2:
+        return creator_without_type::create_multi_arguments<
+                
AggregateFunctionsMinMaxBy<Data<SingleValueDataFixed<TYPE_DATEV2>>>>(
+                argument_types, result_is_nullable, attr);
+    case PrimitiveType::TYPE_DATETIMEV2:
+        return creator_without_type::create_multi_arguments<
+                
AggregateFunctionsMinMaxBy<Data<SingleValueDataFixed<TYPE_DATETIMEV2>>>>(
+                argument_types, result_is_nullable, attr);
     case PrimitiveType::TYPE_ARRAY:
     case PrimitiveType::TYPE_MAP:
     case PrimitiveType::TYPE_STRUCT:
         return creator_without_type::create_multi_arguments<
-                AggregateFunctionTemplate<Data<SingleValueDataComplexType>>>(
+                AggregateFunctionsMinMaxBy<Data<SingleValueDataComplexType>>>(
                 argument_types, result_is_nullable, attr);
     default:
         return nullptr;
diff --git a/be/src/exprs/aggregate/aggregate_function_min_max_impl.h 
b/be/src/exprs/aggregate/aggregate_function_min_max_impl.h
index 48c6db2d67e..e4883564ccb 100644
--- a/be/src/exprs/aggregate/aggregate_function_min_max_impl.h
+++ b/be/src/exprs/aggregate/aggregate_function_min_max_impl.h
@@ -129,6 +129,7 @@ AggregateFunctionPtr 
create_aggregate_function_single_value(const String& name,
         return creator_without_type::create_unary_arguments<
                 
AggregateFunctionsSingleValue<Data<SingleValueDataDecimal<TYPE_DECIMAL256>>>>(
                 argument_types, result_is_nullable, attr);
+    // For Complex type. Currently, only type_array supports min and max.
     case PrimitiveType::TYPE_ARRAY:
     case PrimitiveType::TYPE_MAP:
     case PrimitiveType::TYPE_STRUCT:
diff --git a/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp 
b/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
index d6d60250d0d..c2f4c6295a1 100644
--- a/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
+++ b/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
@@ -33,8 +33,7 @@ void 
register_aggregate_function_combinator_foreachv2(AggregateFunctionSimpleFac
 
 void register_aggregate_function_sum(AggregateFunctionSimpleFactory& factory);
 void register_aggregate_function_minmax(AggregateFunctionSimpleFactory& 
factory);
-void register_aggregate_function_min_by(AggregateFunctionSimpleFactory& 
factory);
-void register_aggregate_function_max_by(AggregateFunctionSimpleFactory& 
factory);
+void register_aggregate_function_max_min_by(AggregateFunctionSimpleFactory& 
factory);
 void register_aggregate_function_avg(AggregateFunctionSimpleFactory& factory);
 void register_aggregate_function_count(AggregateFunctionSimpleFactory& 
factory);
 void register_aggregate_function_count_by_enum(AggregateFunctionSimpleFactory& 
factory);
@@ -88,8 +87,7 @@ AggregateFunctionSimpleFactory& 
AggregateFunctionSimpleFactory::instance() {
     std::call_once(oc, [&]() {
         register_aggregate_function_sum(instance);
         register_aggregate_function_minmax(instance);
-        register_aggregate_function_min_by(instance);
-        register_aggregate_function_max_by(instance);
+        register_aggregate_function_max_min_by(instance);
         register_aggregate_function_avg(instance);
         register_aggregate_function_count(instance);
         register_aggregate_function_count_by_enum(instance);
diff --git a/be/test/exprs/aggregate/agg_min_max_by_test.cpp 
b/be/test/exprs/aggregate/agg_min_max_by_test.cpp
index b6fde246b88..5a9bf798a69 100644
--- a/be/test/exprs/aggregate/agg_min_max_by_test.cpp
+++ b/be/test/exprs/aggregate/agg_min_max_by_test.cpp
@@ -43,8 +43,7 @@ const int agg_test_batch_size = 4096;
 
 namespace doris {
 // declare function
-void register_aggregate_function_min_by(AggregateFunctionSimpleFactory& 
factory);
-void register_aggregate_function_max_by(AggregateFunctionSimpleFactory& 
factory);
+void register_aggregate_function_max_min_by(AggregateFunctionSimpleFactory& 
factory);
 
 class AggMinMaxByTest : public ::testing::TestWithParam<std::string> {};
 
@@ -74,8 +73,7 @@ TEST_P(AggMinMaxByTest, min_max_by_test) {
 
     // Prepare test function and parameters.
     AggregateFunctionSimpleFactory factory;
-    register_aggregate_function_min_by(factory);
-    register_aggregate_function_max_by(factory);
+    register_aggregate_function_max_min_by(factory);
 
     // Test on 2 kind of key types (int32, string).
     for (int i = 0; i < 2; i++) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MaxBy.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MaxBy.java
index cc0324bcf39..63ca76c4800 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MaxBy.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MaxBy.java
@@ -66,11 +66,16 @@ public class MaxBy extends NullableAggregateFunction
 
     @Override
     public void checkLegalityBeforeTypeCoercion() {
-        if (getArgumentType(1).isOnlyMetricType()) {
+        if (getArgumentType(1).isOnlyMetricType() && 
!getArgumentType(1).isArrayType()) {
             throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
         }
     }
 
+    @Override
+    public void checkLegalityAfterRewrite() {
+        checkLegalityBeforeTypeCoercion();
+    }
+
     /**
      * withDistinctAndChildren.
      */
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MinBy.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MinBy.java
index 632abea0322..ab3f7a68e74 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MinBy.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MinBy.java
@@ -66,11 +66,16 @@ public class MinBy extends NullableAggregateFunction
 
     @Override
     public void checkLegalityBeforeTypeCoercion() {
-        if (getArgumentType(1).isOnlyMetricType()) {
+        if (getArgumentType(1).isOnlyMetricType() && 
!getArgumentType(1).isArrayType()) {
             throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
         }
     }
 
+    @Override
+    public void checkLegalityAfterRewrite() {
+        checkLegalityBeforeTypeCoercion();
+    }
+
     /**
      * withDistinctAndChildren.
      */
diff --git 
a/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions2.out
 
b/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions2.out
index 7df61ecbf6e..41ca9183b9c 100644
--- 
a/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions2.out
+++ 
b/regression-test/data/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions2.out
@@ -375,13 +375,78 @@ true
 -- !maxmin_array_1 --
 \N     \N
 
+-- !maxminby_array_1 --
+\N     \N
+
+-- !maxminby_map_1 --
+\N     \N
+
+-- !maxminby_struct_1 --
+\N     \N
+
 -- !maxmin_array_2 --
 [7]    [1, 2, 3]
-[1, 2, 3, 4]   [1, 2]
+[1, 2, 5]      [1, 2]
 [11, 22, 33, 44]       [3, 1]
 [10]   []
 [11, null, null, 55]   [1, null, null, 4]
 
+-- !maxminby_array_2 --
+[1, 2, 5]      [11, 22, 33, 44]
+
+-- !maxminby_array_3 --
+{"A":10, "B":1}        {"x":50, "y":60}
+
+-- !maxminby_array_4 --
+{"a":10, "b":"tt"}     {"a":4, "b":"delta"}
+
+-- !maxminby_array_5 --
+1      [5, 6]  [7]
+2      [1, 2, 5]       [1, 2]
+3      [3, 1]  [11, 22, 33, 44]
+4      [3, 1]  [10]
+5      [1, null, 3, 4] [1, 2, 3, 4]
+
+-- !maxminby_map_2 --
+{"foo":1, "bar":2}     {"A":10, "B":1}
+
+-- !maxminby_map_3 --
+1      {"k1":30, "k2":15}      {"x":100, "y":200}
+2      {"foo":1, "bar":2}      {"foo":2, "bar":1}
+3      {"key1":99, "key2":98}  {"A":10, "B":1}
+4      {"key1":99, "key2":98}  {"A":5, "B":10}
+5      {"A":null, "B":null}    {"A":null, "B":5}
+
+-- !maxminby_map_4 --
+1      {"x":100, "y":200}      {"k1":10, "k2":20}
+2      {"foo":1, "bar":2}      {"foo":2, "bar":1}
+3      {"A":10, "B":1} {"key1":99, "key2":98}
+4      {"A":5, "B":10} {"x":50, "y":60}
+5      {"A":10, "B":5} {"A":null, "B":null}
+
+-- !maxminby_struct_2 --
+{"a":5, "b":"echo"}    {"a":10, "b":"tt"}
+
+-- !maxminby_struct_3 --
+1      {"a":2, "b":"beta"}     {"a":3, "b":"gamma"}
+2      {"a":5, "b":"echo"}     {"a":6, "b":"zulu"}
+3      {"a":8, "b":"eight"}    {"a":10, "b":"tt"}
+4      {"a":8, "b":"eight"}    {"a":9, "b":"nine"}
+5      {"a":null, "b":null}    {"a":null, "b":"ten"}
+
+-- !maxminby_struct_4 --
+1      {"a":3, "b":"gamma"}    {"a":1, "b":"alpha"}
+2      {"a":5, "b":"echo"}     {"a":6, "b":"zulu"}
+3      {"a":10, "b":"tt"}      {"a":8, "b":"eight"}
+4      {"a":9, "b":"nine"}     {"a":4, "b":"delta"}
+5      {"a":10, "b":"ten"}     {"a":null, "b":null}
+
 -- !maxmin_array_3 --
 [[3, 4], [3, 4]]       [[1, 2], [3, 4]]
 
+-- !maxminby_array_6 --
+3      1
+
+-- !maxminby_array_7 --
+[[3, 4], [3, 4]]       [[1, 2], [3, 4]]
+
diff --git 
a/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions2.groovy
 
b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions2.groovy
index e2f186a61f3..3d9258f6568 100644
--- 
a/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions2.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_all_functions2.groovy
@@ -287,31 +287,49 @@ suite("test_aggregate_all_functions2") {
     """
 
     qt_maxmin_array_1 """SELECT max(arr), min(arr) from test_maxmin"""
+    qt_maxminby_array_1 """SELECT max_by(arr, weight), min_by(arr, weight) 
from test_maxmin"""
+    qt_maxminby_map_1 """SELECT max_by(mp, weight), min_by(mp, weight) from 
test_maxmin"""
+    qt_maxminby_struct_1 """SELECT max_by(st, weight), min_by(st, weight) from 
test_maxmin"""
 
     sql """
         INSERT INTO test_maxmin (id, arr, mp, st, weight) VALUES
         (1,  [1,2,3],            {"k1": 10, "k2": 20},         
NAMED_STRUCT("a", 1, "b", "alpha"),   5),
         (1,  [5,6],              {"k1": 30, "k2": 15},         
NAMED_STRUCT("a", 2, "b", "beta"),    10),
         (1,  [7],                {"x": 100, "y": 200},         
NAMED_STRUCT("a", 3, "b", "gamma"),   3),
-        (2,  [1,2,3],            {"foo": 1, "bar": 2},         
NAMED_STRUCT("a", 5, "b", "echo"),    15),
+        (2,  [1,2,5],            {"foo": 1, "bar": 2},         
NAMED_STRUCT("a", 5, "b", "echo"),    15),
         (2,  [1,2],              {"foo": 2, "bar": 1},         
NAMED_STRUCT("a", 6, "b", "zulu"),    7),
         (2,  [1,2,3,4],          {"key1": -1, "key2": -5},     
NAMED_STRUCT("a", 7, "b", "seven"),   12),
         (3,  [3,1],              {"key1": 99, "key2": 98},     
NAMED_STRUCT("a", 8, "b", "eight"),   9),
         (3,  [10],               {"A": 5, "B": 10},            
NAMED_STRUCT("a", 9, "b", "nine"),    6),
-        (3,  [11,22,33,44],      {"A": 10, "B": 5},            
NAMED_STRUCT("a", 10,"b", "ten"),    1),
+        (3,  [11,22,33,44],      {"A": 10, "B": 1},            
NAMED_STRUCT("a", 10,"b", "tt"),    1),
         (3,  null,               null,                         null,           
                     17),
+        (3,  null,               null,                         null,           
                     -1),
         (4,  [3,1],              {"key1": 99, "key2": 98},     
NAMED_STRUCT("a", 8, "b", "eight"),   9),
         (4,  [10],               {"A": 5, "B": 10},            
NAMED_STRUCT("a", 9, "b", "nine"),    6),
         (4,  [],                 {"x": 50,  "y": 60},          
NAMED_STRUCT("a", 4, "b", "delta"),   8),
-        (5, [1,2,3,4],           {"A": null, "B": 5},          
NAMED_STRUCT("a", null,"b", "ten"),   1),
-        (5, [1,2,null,4],        {"A": 100, "B": null},        
NAMED_STRUCT("a", 10,"b", null),      1),
-        (5, [1,null,null,4],     {"A": null, "B": null},       
NAMED_STRUCT("a", null,"b", null),    1),
-        (5, [1,null,3,4],        {"A": null, "B": null},       
NAMED_STRUCT("a", null,"b", null),    1),
-        (5, [11,null,null,55],   {"A": 10, "B": 5},            
NAMED_STRUCT("a", 10,"b", "ten"),     1);
+        (5, [1,2,3,4],           {"A": null, "B": 5},          
NAMED_STRUCT("a", null,"b", "ten"),   2),
+        (5, [1,2,null,4],        {"A": 100, "B": null},        
NAMED_STRUCT("a", 10,"b", null),      3),
+        (5, [1,null,null,4],     {"A": null, "B": null},       
NAMED_STRUCT("a", null,"b", null),    4),
+        (5, [1,null,3,4],        {"A": null, "B": null},       
NAMED_STRUCT("a", null,"b", null),    5),
+        (5, [11,null,null,55],   {"A": 10, "B": 5},            
NAMED_STRUCT("a", 10,"b", "ten"),     null);
     """
 
     qt_maxmin_array_2 """SELECT max(arr), min(arr) from test_maxmin group by 
id order by id"""
+    qt_maxminby_array_2 """SELECT max_by(arr, weight), min_by(arr, weight) 
from test_maxmin"""
+    qt_maxminby_array_3 """SELECT max_by(mp, arr), min_by(mp, arr) from 
test_maxmin"""
+    qt_maxminby_array_4 """SELECT max_by(st, arr), min_by(st, arr) from 
test_maxmin"""
 
+    qt_maxminby_array_5 """SELECT id, max_by(arr, weight), min_by(arr, weight) 
from test_maxmin group by id order by id"""
+
+    qt_maxminby_map_2 """SELECT max_by(mp, weight), min_by(mp, weight) from 
test_maxmin"""
+    qt_maxminby_map_3 """SELECT id, max_by(mp, weight), min_by(mp, weight) 
from test_maxmin group by id order by id"""
+    qt_maxminby_map_4 """SELECT id, max_by(mp, arr), min_by(mp, arr) from 
test_maxmin group by id order by id"""
+
+    qt_maxminby_struct_2 """SELECT max_by(st, weight), min_by(st, weight) from 
test_maxmin"""
+    qt_maxminby_struct_3 """SELECT id, max_by(st, weight), min_by(st, weight) 
from test_maxmin group by id order by id"""
+    qt_maxminby_struct_4 """SELECT id, max_by(st, arr), min_by(st, arr) from 
test_maxmin group by id order by id"""
+
+    sql "DROP TABLE IF EXISTS test_nested_maxmin";
     sql """
         CREATE TABLE test_nested_maxmin (
             id INT,
@@ -330,4 +348,6 @@ suite("test_aggregate_all_functions2") {
     """
 
     qt_maxmin_array_3 """SELECT max(arr), min(arr) from test_nested_maxmin"""
+    qt_maxminby_array_6 """SELECT max_by(weight, arr), min_by(weight, arr) 
from test_nested_maxmin"""
+    qt_maxminby_array_7 """SELECT max_by(arr, weight), min_by(arr, weight) 
from test_nested_maxmin"""
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to