[opt](nereids) convert or to inpredicate and optimize inpredicate partition prune (#28316)
This commit is contained in:
@ -396,11 +396,12 @@ public class OneRangePartitionEvaluator
|
||||
if (inPredicate.getCompareExpr() instanceof Slot
|
||||
&& inPredicate.getOptions().stream().allMatch(Literal.class::isInstance)) {
|
||||
Slot slot = (Slot) inPredicate.getCompareExpr();
|
||||
ColumnRange unionLiteralRange = inPredicate.getOptions()
|
||||
.stream()
|
||||
.map(Literal.class::cast)
|
||||
.map(ColumnRange::singleton)
|
||||
.reduce(ColumnRange.empty(), ColumnRange::union);
|
||||
ColumnRange unionLiteralRange = ColumnRange.empty();
|
||||
ColumnRange slotRange = result.childrenResult.get(0).columnRanges.get(slot);
|
||||
for (Expression expr : inPredicate.getOptions()) {
|
||||
unionLiteralRange = unionLiteralRange.union(
|
||||
slotRange.intersect(ColumnRange.singleton((Literal) expr)));
|
||||
}
|
||||
Map<Slot, ColumnRange> slotRanges = result.childrenResult.get(0).columnRanges;
|
||||
result = intersectSlotRange(result, slotRanges, slot, unionLiteralRange);
|
||||
}
|
||||
|
||||
@ -113,6 +113,7 @@ public class PartitionPruner extends DefaultExpressionRewriter<Void> {
|
||||
partitionTableType))
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
|
||||
partitionPredicate = OrToIn.INSTANCE.rewrite(partitionPredicate, null);
|
||||
PartitionPruner partitionPruner = new PartitionPruner(evaluators, partitionPredicate);
|
||||
//TODO: we keep default partition because it's too hard to prune it, we return false in canPrune().
|
||||
return partitionPruner.prune();
|
||||
|
||||
Reference in New Issue
Block a user