pick #36345
This commit is contained in:
@ -249,8 +249,9 @@ public class PartitionInfo implements Writable {
|
||||
return isAutoCreatePartitions;
|
||||
}
|
||||
|
||||
// forbid change metadata.
|
||||
public ArrayList<Expr> getPartitionExprs() {
|
||||
return this.partitionExprs;
|
||||
return Expr.cloneList(this.partitionExprs);
|
||||
}
|
||||
|
||||
public void checkPartitionItemListsMatch(List<PartitionItem> list1, List<PartitionItem> list2) throws DdlException {
|
||||
|
||||
@ -34,7 +34,9 @@ public abstract class PartitionPruneTestBase extends TestWithFeService {
|
||||
}
|
||||
|
||||
private void assertExplainContains(String sql, String subString) throws Exception {
|
||||
Assert.assertTrue(String.format("sql=%s, expectResult=%s", sql, subString),
|
||||
Assert.assertTrue(
|
||||
String.format("sql=%s, expectResult=%s, but got %s", sql, subString,
|
||||
getSQLPlanOrErrorMsg("explain " + sql)),
|
||||
getSQLPlanOrErrorMsg("explain " + sql).contains(subString));
|
||||
}
|
||||
|
||||
|
||||
@ -206,9 +206,6 @@ public class RangePartitionPruneTest extends PartitionPruneTestBase {
|
||||
"partitions=6/8");
|
||||
addCase("select /*+ SET_VAR(enable_nereids_planner=false) */ * from test.test_to_date_trunc where event_day= \"2023-08-07 11:00:00\" ",
|
||||
"partitions=1/2");
|
||||
addCase("select /*+ SET_VAR(enable_nereids_planner=false) */ * from test.test_to_date_trunc where date_trunc(event_day, \"day\")= \"2023-08-07 11:00:00\" ",
|
||||
"partitions=1/2");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -91,4 +91,35 @@ suite("test_date_function_prune") {
|
||||
sql "select * from dp where date_time > str_to_date('2020-01-02','%Y-%m-%d')"
|
||||
contains("partitions=2/3 (p2,p3)")
|
||||
}
|
||||
|
||||
sql "drop table if exists test_to_date_trunc"
|
||||
sql """
|
||||
CREATE TABLE test_to_date_trunc(
|
||||
event_day DATETIME NOT NULL
|
||||
)
|
||||
DUPLICATE KEY(event_day)
|
||||
AUTO PARTITION BY range (date_trunc(event_day, "day")) (
|
||||
PARTITION `p20230807` values [(20230807 ), (20230808 )),
|
||||
PARTITION `p20020106` values [(20020106 ), (20020107 ))
|
||||
)
|
||||
DISTRIBUTED BY HASH(event_day) BUCKETS 4
|
||||
PROPERTIES("replication_num" = "1");
|
||||
"""
|
||||
explain {
|
||||
sql """ select /*+ SET_VAR(enable_nereids_planner=false) */ * from test_to_date_trunc where date_trunc(event_day, "day")= "2023-08-07 11:00:00" """
|
||||
contains("partitions=0/2")
|
||||
}
|
||||
explain {
|
||||
sql """ select * from test_to_date_trunc where date_trunc(event_day, "day")= "2023-08-07 11:00:00" """
|
||||
contains("VEMPTYSET")
|
||||
}
|
||||
sql """ insert into test_to_date_trunc values ("20230807000000"); """
|
||||
explain {
|
||||
sql """ select /*+ SET_VAR(enable_nereids_planner=false) */ * from test_to_date_trunc where date_trunc(event_day, "day")= "2023-08-07 11:00:00" """
|
||||
contains("partitions=1/2 (p20230807)")
|
||||
}
|
||||
explain {
|
||||
sql """ select * from test_to_date_trunc where date_trunc(event_day, "day")= "2023-08-07 11:00:00" """
|
||||
contains("partitions=1/2 (p20230807)")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user