[fix](nereids) temp partition is always pruned (#27636)

This commit is contained in:
minghong
2023-11-28 14:18:14 +08:00
committed by GitHub
parent 31fe48111b
commit 2ea1e9db44
4 changed files with 46 additions and 1 deletions

View File

@ -129,6 +129,16 @@ public class PartitionInfo implements Writable {
}
}
/**
* @return both normal partition and temp partition
*/
public Map<Long, PartitionItem> getAllPartitions() {
HashMap all = new HashMap<>();
all.putAll(idToTempItem);
all.putAll(idToItem);
return all;
}
public PartitionItem getItem(long partitionId) {
PartitionItem item = idToItem.get(partitionId);
if (item == null) {

View File

@ -103,7 +103,7 @@ public class PartitionPruner extends DefaultExpressionRewriter<Void> {
*/
public static List<Long> prune(List<Slot> partitionSlots, Expression partitionPredicate,
PartitionInfo partitionInfo, CascadesContext cascadesContext, PartitionTableType partitionTableType) {
return prune(partitionSlots, partitionPredicate, partitionInfo.getIdToItem(false), cascadesContext,
return prune(partitionSlots, partitionPredicate, partitionInfo.getAllPartitions(), cascadesContext,
partitionTableType);
}

View File

@ -24,3 +24,6 @@
-- !sql --
1 aaa aaa
-- !sql --
16 1234 t

View File

@ -88,4 +88,36 @@ suite("query_on_specific_partition") {
qt_sql """
SELECT * FROM test_iot PARTITION p1;
"""
sql """
DROP TABLE IF EXISTS ut_p;
"""
sql """
CREATE TABLE ut_p (
id BIGINT,
val BIGINT,
str VARCHAR(114)
) unique KEY(`id`)
PARTITION BY RANGE(`id`)
(
PARTITION `p1` VALUES LESS THAN ('5'),
PARTITION `p2` VALUES LESS THAN ('10')
)
DISTRIBUTED BY HASH(`id`) BUCKETS 3
PROPERTIES (
"replication_num"="1"
);
"""
sql """ALTER TABLE ut_p ADD TEMPORARY PARTITION tp1 VALUES [("15"), ("20"));"""
sql "INSERT INTO ut_p TEMPORARY PARTITION(tp1) values(16,1234, 't');"
sql "SET enable_fallback_to_original_planner=false"
qt_sql """select * from ut_p temporary partitions(tp1);"""
}