Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ public Map<Long, PartitionItem> getIdToItem(boolean isTemp) {
}
}

/**
* @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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<Long> prune() {
*/
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);
}

Expand Down
3 changes: 3 additions & 0 deletions regression-test/data/nereids_syntax_p0/select_partition.out
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
-- !sql --
1 aaa aaa

-- !sql --
16 1234 t

32 changes: 32 additions & 0 deletions regression-test/suites/nereids_syntax_p0/select_partition.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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);"""



}