xzj7019 commented on code in PR #39252:
URL: https://github.com/apache/doris/pull/39252#discussion_r1735674864


##########
regression-test/suites/nereids_rules_p0/max_min_filter_push_down/max_min_filter_push_down.groovy:
##########
@@ -0,0 +1,207 @@
+// 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.
+suite("max_min_filter_push_down") {
+    sql "SET enable_nereids_planner=true"
+    sql "SET enable_fallback_to_original_planner=false"
+    sql "SET ignore_shape_nodes='PhysicalDistribute,PhysicalProject'"
+
+    sql "drop table if exists max_min_filter_push_down1"
+    sql"""
+    CREATE TABLE max_min_filter_push_down1 (
+        id INT,
+        value1 INT,
+        value2 VARCHAR(50)
+    ) properties("replication_num"="1");
+    """
+
+    sql """
+    INSERT INTO max_min_filter_push_down1 (id, value1, value2) VALUES
+    (1, 10, 'A'),(1, 11, 'A'),(2, 20, 'B'),(2, 73, 'B'),(2, 19, 'B'),(3, 30, 
'C'),(3, 61, 'C'),(4, 40, 'D'),(4, 43, 'D'),(4, 45, 'D');
+    """
+    sql "drop table if exists max_min_filter_push_down_empty"
+    sql "create table max_min_filter_push_down_empty like 
max_min_filter_push_down1"
+
+    qt_scalar_agg_empty_table """
+    explain shape plan
+    select min(value1) from max_min_filter_push_down_empty having min(value1) 
<40 and min(value1) <20;
+    """
+    qt_min """
+    explain shape plan
+    select id,min(value1) from max_min_filter_push_down1 group by id having 
min(value1) <40 and min(value1) <20;
+    """
+    qt_max """
+    explain shape plan
+    select id,max(value1) from max_min_filter_push_down1 group by id having 
max(value1) >40;
+    """
+
+    qt_min_expr """
+    explain shape plan
+    select id,min(value1+1) from max_min_filter_push_down1 group by id having 
min(value1+1) <40 and min(value1+1) <20;
+    """
+    qt_max_expr """
+    explain shape plan
+    select id,max(abs(value1)+1) from max_min_filter_push_down1 group by id 
having max(abs(value1)+1) >40;
+    """
+
+    qt_min_commute """
+    explain shape plan
+    select id,min(value1) from max_min_filter_push_down1 group by id having 
40>min(value1);
+    """
+    qt_max """
+    explain shape plan
+    select id,max(value1) from max_min_filter_push_down1 group by id having 
40<max(value1); 
+    """
+
+    qt_min_equal """
+    explain shape plan
+    select id,min(value1) from max_min_filter_push_down1 group by id having 
min(value1) <=40 and min(value1) <=20;
+    """
+    qt_max_equal """
+    explain shape plan
+    select id,max(value1) from max_min_filter_push_down1 group by id having 
max(value1) >=40;
+    """
+
+    qt_min_commute_equal """
+    explain shape plan
+    select id,min(value1) from max_min_filter_push_down1 group by id having 
40>=min(value1);
+    """
+    qt_max_commute_equal """
+    explain shape plan
+    select id,max(value1) from max_min_filter_push_down1 group by id having 
40<=max(value1); 
+    """
+
+    qt_has_other_agg_func """
+    explain shape plan
+    select id,max(value1),min(value1) from max_min_filter_push_down1 group by 
id having 40<=max(value1); 
+    """
+
+    qt_min_scalar_agg """
+    explain shape plan
+    select min(value1) from max_min_filter_push_down1 having min(value1) <40;
+    """
+    qt_max_scalar_agg """
+    explain shape plan
+    select max(value1) from max_min_filter_push_down1 having max(value1) >40;
+    """
+    qt_max_scalar_agg """
+    explain shape plan
+    select max(value1) from max_min_filter_push_down1 having 40<max(value1); 
+    """
+
+    qt_min_equal_scalar_agg """
+    explain shape plan
+    select min(value1) from max_min_filter_push_down1 having min(value1) <=40 
and min(value1) <=20;
+    """
+    qt_max_equal_scalar_agg """
+    explain shape plan
+    select max(value1) from max_min_filter_push_down1 having max(value1) >=40;
+    """
+
+    qt_scalar_agg_empty_table_res """
+    select min(value1) from max_min_filter_push_down_empty having min(value1) 
<40 and min(value1) <20;
+    """
+    qt_min_res """
+    select id,min(value1) from max_min_filter_push_down1 group by id having 
min(value1) <40 and min(value1) <20 order by 1,2;
+    """
+    qt_max_res """
+    select id,max(value1) from max_min_filter_push_down1 group by id having 
max(value1) >40 order by 1,2;
+    """
+    qt_min_expr_res """
+    select id,min(value1+1) from max_min_filter_push_down1 group by id having 
min(value1+1) <40 and min(value1+1) <20 order by 1,2;
+    """
+    qt_max_expr_res """
+    select id,max(abs(value1)+1) from max_min_filter_push_down1 group by id 
having max(abs(value1)+1) >40 order by 1,2;
+    """
+    qt_min_commute_res """
+    select id,min(value1) from max_min_filter_push_down1 group by id having 
40>min(value1) order by 1,2;
+    """
+    qt_max_res """
+    select id,max(value1) from max_min_filter_push_down1 group by id having 
40<max(value1) order by 1,2; 
+    """
+
+    qt_min_equal_res """
+    select id,min(value1) from max_min_filter_push_down1 group by id having 
min(value1) <=40 and min(value1) <=20  order by 1,2;
+    """
+    qt_max_equal_res """
+    select id,max(value1) from max_min_filter_push_down1 group by id having 
max(value1) >=40  order by 1,2;
+    """
+
+    qt_min_commute_equal_res """
+    select id,min(value1) from max_min_filter_push_down1 group by id having 
40>=min(value1)  order by 1,2;
+    """
+    qt_max_commute_equal_res """
+    select id,max(value1) from max_min_filter_push_down1 group by id having 
40<=max(value1) order by 1,2; 
+    """
+
+    qt_has_other_agg_func_res """
+    select id,max(value1),min(value1) from max_min_filter_push_down1 group by 
id having 40<=max(value1) order by 1,2; 
+    """
+
+    qt_min_scalar_agg_res """
+    select min(value1) from max_min_filter_push_down1 having min(value1) <40;
+    """
+    qt_max_scalar_agg_res """
+    select max(value1) from max_min_filter_push_down1 having max(value1) >40;
+    """
+    qt_max_scalar_agg_res """
+    select max(value1) from max_min_filter_push_down1 having 40<max(value1); 
+    """
+
+    qt_min_equal_scalar_agg_res """
+    select min(value1) from max_min_filter_push_down1 having min(value1) <=40 
and min(value1) <=20;
+    """
+    qt_max_equal_scalar_agg_res """
+    select max(value1) from max_min_filter_push_down1 having max(value1) >=40;
+    """
+

Review Comment:
   cases whose literal is a composed expression which can be folded?



-- 
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-unsubscr...@doris.apache.org

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


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

Reply via email to