[regression](nereids) add test case for partition prune (#26849)

* list selected partition name in explain
* add prune partition test case (multi-range key)
This commit is contained in:
minghong
2023-11-14 11:51:32 +08:00
committed by GitHub
parent f6a9914bc7
commit f1d90ffc4e
4 changed files with 252 additions and 4 deletions

View File

@ -222,8 +222,12 @@ public class OneRangePartitionEvaluator
if (expr.getDataType() instanceof BooleanType && !(expr instanceof Literal)
&& result.childrenResult.stream().anyMatch(childResult ->
childResult.columnRanges.values().stream().anyMatch(ColumnRange::isEmptyRange))) {
// this assumes that for expression: func(A)
// if A reject partition, then func(A) reject partition.
// implement visitFunc for Func if Func does not satisfy the above assumption.
return new EvaluateRangeResult(BooleanLiteral.FALSE, result.columnRanges, result.childrenResult);
}
// assumption: for func(A), if A accept range (n, m), then func(A) accept range (n, m).
return result;
}

View File

@ -1239,8 +1239,11 @@ public class OlapScanNode extends ScanNode {
output.append(getRuntimeFilterExplainString(false));
}
output.append(prefix).append(String.format("partitions=%s/%s, tablets=%s/%s", selectedPartitionNum,
olapTable.getPartitions().size(), selectedTabletsNum, totalTabletsNum));
String selectedPartitions = getSelectedPartitionIds().stream().sorted()
.map(id -> olapTable.getPartition(id).getName())
.collect(Collectors.joining(","));
output.append(prefix).append(String.format("partitions=%s/%s (%s), tablets=%s/%s", selectedPartitionNum,
olapTable.getPartitions().size(), selectedPartitions, selectedTabletsNum, totalTabletsNum));
// We print up to 3 tablet, and we print "..." if the number is more than 3
if (scanTabletIds.size() > 3) {
List<Long> firstTenTabletIds = scanTabletIds.subList(0, 3);