Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] fix list partition multi values' probelm (backport #51036) #52571

Merged
merged 1 commit into from
Nov 7, 2024
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 @@ -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
Loading