Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Murphy <[email protected]>
  • Loading branch information
murphyatwork committed Dec 3, 2024
1 parent c891f89 commit 406cc24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,26 +229,28 @@ private OptExpression optimizeWithPartitionPrune(OptExpression optExpression,
if (CollectionUtils.isEmpty(sorted)) {
return null;
}
// TODO: in theory if we can confirm one partition contains only NULL values, we can rule out these
// partitions from sorted. But currently a range-partition can contains both NULL value and regular
// values
if (nullPartitions.contains(sorted.get(0))) {
return null;
for (long partitionId : sorted) {
pruned.add(partitionId);
// at least reserve one non-null partition, null-partition might be useless
if (!nullPartitions.contains(partitionId)) {
break;
}
}
pruned.add(sorted.get(0));
}

if (hasMinMax.second) {
List<Long> sorted = partitionInfo.getSortedPartitions(false);
sorted.retainAll(nonEmptyPartitionIds);
sorted.removeAll(nullPartitions);
if (CollectionUtils.isEmpty(sorted)) {
return null;
}
if (nullPartitions.contains(sorted.get(0))) {
return null;
for (long partitionId : sorted) {
pruned.add(partitionId);
// at least reserve one non-null partition, null-partition might be useless
if (!nullPartitions.contains(partitionId)) {
break;
}
}
pruned.add(sorted.get(0));
}

LogicalOlapScanOperator scan = new LogicalOlapScanOperator.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,11 @@ public void testMinMaxPrune_PartitionPrune() throws Exception {
starRocksAssert.ddl("alter table t2_dup add partition p20240104 values less than('2024-01-04') ");
starRocksAssert.ddl("alter table t2_dup add partition p20240105 values less than('2024-01-05') ");

starRocksAssert.query("select min(c1) from t2_dup").explainContains("partitions=1/5");
starRocksAssert.query("select min(c1) from t2_dup").explainContains("partitions=2/5");
starRocksAssert.query("select max(c1) from t2_dup").explainContains("partitions=1/5");
starRocksAssert.query("select min(c1), max(c1) from t2_dup").explainContains("partitions=2/5");
starRocksAssert.query("select min(c1)+1, max(c1)-1 from t2_dup").explainContains("partitions=2/5");
starRocksAssert.query("select min(c1) from t2_dup limit 10").explainContains("partitions=1/5");
starRocksAssert.query("select min(c1), max(c1) from t2_dup").explainContains("partitions=3/5");
starRocksAssert.query("select min(c1)+1, max(c1)-1 from t2_dup").explainContains("partitions=3/5");
starRocksAssert.query("select min(c1) from t2_dup limit 10").explainContains("partitions=2/5");

// manually specify partition
starRocksAssert.query("select min(c1) from t2_dup partition p20240101").explainContains("partitions=1/5");
Expand Down

0 comments on commit 406cc24

Please sign in to comment.