Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: before-Sunrise <[email protected]>
  • Loading branch information
before-Sunrise committed Nov 1, 2024
1 parent 94938dd commit 82a06ea
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public Map<Long, List<String>> getIdToValues() {
* @param id
* @return true if the partition can be pruned
*/
public boolean pruneById(long id) {
public boolean isSingleValuePartition(long id) {
List<String> values = getIdToValues().get(id);
if (values != null && values.size() == 1) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ private Set<Long> evalBinaryPredicate(BinaryPredicateOperator binaryPredicate) {
} else {
Set<Long> partitionIds = partitionValueMap.get(literal);
for (Long id : partitionIds) {
if (listPartitionInfo.pruneById(id)) {
if (listPartitionInfo.isSingleValuePartition(id)) {
matches.remove(id);
}
}
Expand Down Expand Up @@ -706,7 +706,18 @@ private Set<Long> evalInPredicate(InPredicateOperator inPredicate) {
Set<Long> partitions = partitionValueMap.get(literal);
if (partitions != null) {
if (inPredicate.isNotIn()) {
matches.removeAll(partitions);
// external table, one partition column for one partition can only have one value
if (listPartitionInfo == null) {
matches.removeAll(partitions);
} else {
// for olap table, if one partition is multi value partition like PARTITION pCalifornia VALUES IN ("Los Angeles","San Francisco","San Diego")
// and we have a not in predicate like city not in ("Los Angeles"), it's not safe to remove this partition
for (Long id : partitions) {
if (listPartitionInfo.isSingleValuePartition(id)) {
matches.remove(id);
}
}
}
} else {
matches.addAll(partitions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@ public void testMinMaxPrune_ListValues() throws Exception {
starRocksAssert.query("select min(c1-1)+1, max(c1-1)-1 from t1_list_multi_values")
.explainContains("OlapScanNode");

// multi-value partition doesn't support partition prune
starRocksAssert.query("select * from t1_list_multi_values where c1 not in (10, 2, 8, 5)")
.explainContains("partitions=4/4");

starRocksAssert.query("select * from t1_list_multi_values where c1 != 10")
.explainContains("partitions=4/4");

// TODO: not supported
// multi-item list partition
Expand Down

0 comments on commit 82a06ea

Please sign in to comment.