yiguolei commented on code in PR #29242:
URL: https://github.com/apache/doris/pull/29242#discussion_r1437999769


##########
regression-test/suites/nereids_p0/explain/test_pushdown_explain.groovy:
##########
@@ -65,4 +65,131 @@ suite("test_pushdown_explain") {
         sql("select count(cast(lo_orderkey as bigint)) from test_lineorder;")
         contains "pushAggOp=COUNT"
     }
+
+    sql "DROP TABLE IF EXISTS table_unique"
+    sql """ 
+        CREATE TABLE `table_unique` (
+            `user_id` LARGEINT NOT NULL COMMENT '\"用户id\"',
+            `username` VARCHAR(50) NOT NULL COMMENT '\"用户昵称\"',
+            `val` VARCHAR(50) NULL
+        ) ENGINE=OLAP
+        UNIQUE KEY(`user_id`, `username`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`user_id`) BUCKETS 1
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "disable_auto_compaction" = "false"
+        );
+    """
+    sql """ 
+        insert into table_unique 
values(1,"asd","cc"),(2,"qwe","vvx"),(3,"ffsd","mnm"),(4,"qdf","ll"),(5,"cvfv","vff");
+    """
+    sql "set enable_pushdown_minmax_on_unique = true;"
+    explain {
+        sql("select min(user_id) from table_unique;")
+        contains "pushAggOp=MINMAX"
+    }
+    explain {
+        sql("select max(user_id) from table_unique;")
+        contains "pushAggOp=MINMAX"
+    }
+    explain {
+        sql("select min(username) from table_unique;")
+        contains "pushAggOp=MINMAX"
+    }
+    explain {
+        sql("select max(username) from table_unique;")
+        contains "pushAggOp=MINMAX"
+    }
+
+    sql "set enable_pushdown_minmax_on_unique = false;"
+    explain {
+        sql("select min(user_id) from table_unique;")
+        contains "pushAggOp=NONE"
+    }
+    explain {
+        sql("select max(user_id) from table_unique;")
+        contains "pushAggOp=NONE"
+    }
+    explain {
+        sql("select min(username) from table_unique;")
+        contains "pushAggOp=NONE"
+    }
+    explain {
+        sql("select max(username) from table_unique;")
+        contains "pushAggOp=NONE"
+    }
+
+    qt_select_1 "select min(user_id) from table_unique;"
+    qt_select_2 "select max(user_id) from table_unique;"
+    qt_select_3 "select min(username) from table_unique;"
+    qt_select_4 "select max(username) from table_unique;"
+    qt_select_5 "select min(val) from table_unique;"
+    qt_select_6 "select max(val) from table_unique;"
+    sql """
+        update table_unique set val = "zzz" where user_id = 1;
+    """
+
+    qt_select_7 "select min(user_id) from table_unique;"
+    qt_select_8 "select max(user_id) from table_unique;"
+    qt_select_9 "select min(username) from table_unique;"
+    qt_select_10 "select max(username) from table_unique;"
+    qt_select_11 "select min(val) from table_unique;"
+    qt_select_12 "select max(val) from table_unique;"
+
+    sql """
+        delete from table_unique where user_id = 2;
+    """
+
+    qt_select_13 "select min(user_id) from table_unique;"
+    qt_select_14 "select max(user_id) from table_unique;"
+    qt_select_15 "select min(username) from table_unique;"
+    qt_select_16 "select max(username) from table_unique;"
+    qt_select_17 "select min(val) from table_unique;"
+    qt_select_18 "select max(val) from table_unique;"
+
+
+    sql "DROP TABLE IF EXISTS table_agg"
+    sql """ 
+        CREATE TABLE `table_agg` (
+            `user_id` LARGEINT NOT NULL COMMENT '\"用户id\"',
+            `username` VARCHAR(50) NOT NULL COMMENT '\"用户昵称\"',
+            `val` VARCHAR(50) max NULL 
+        ) ENGINE=OLAP
+        AGGREGATE KEY(`user_id`, `username`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`user_id`) BUCKETS 1
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "disable_auto_compaction" = "false"
+        );
+    """
+
+    sql """ 
+        insert into table_agg 
values(1,"asd","cc"),(2,"qwe","vvx"),(3,"ffsd","mnm"),(4,"qdf","ll"),(5,"cvfv","vff");

Review Comment:
   You will not test unique key behavior, because the key is all different.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to