Skip to content

Commit

Permalink
[regression](nereids) add test case for partition prune (apache#26849)
Browse files Browse the repository at this point in the history
* list selected partition name in explain
* add prune partition test case (multi-range key)
  • Loading branch information
englefly committed Nov 24, 2023
1 parent ff18510 commit 40a36c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,12 @@ public EvaluateRangeResult visit(Expression expr, EvaluateRangeInput context) {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1196,8 +1196,11 @@ public String getNodeExplainString(String prefix, TExplainLevel detailLevel) {
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);
Expand Down
4 changes: 2 additions & 2 deletions regression-test/data/performance_p0/redundant_conjuncts.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PLAN FRAGMENT 0
0:VOlapScanNode
TABLE: default_cluster:regression_test_performance_p0.redundant_conjuncts(redundant_conjuncts), PREAGGREGATION: OFF. Reason: No AggregateInfo
PREDICATES: `k1` = 1
partitions=0/1, tablets=0/0, tabletList=
partitions=0/1 (), tablets=0/0, tabletList=
cardinality=0, avgRowSize=8.0, numNodes=1
pushAggOp=NONE

Expand All @@ -25,7 +25,7 @@ PLAN FRAGMENT 0
0:VOlapScanNode
TABLE: default_cluster:regression_test_performance_p0.redundant_conjuncts(redundant_conjuncts), PREAGGREGATION: OFF. Reason: No AggregateInfo
PREDICATES: `k1` = 1 OR `k1` = 2
partitions=0/1, tablets=0/0, tabletList=
partitions=0/1 (), tablets=0/0, tabletList=
cardinality=0, avgRowSize=8.0, numNodes=1
pushAggOp=NONE

0 comments on commit 40a36c4

Please sign in to comment.