[Fix](nereids) fix condition function partition prune (#39298) (#39332)

cherry-pick #39298 to branch-2.1
This commit is contained in:
feiniaofeiafei
2024-08-14 18:32:50 +08:00
committed by GitHub
parent d2709f8600
commit 701e23b65b
2 changed files with 52 additions and 15 deletions

View File

@ -181,21 +181,7 @@ public class OneRangePartitionEvaluator
@Override
public EvaluateRangeResult visit(Expression expr, EvaluateRangeInput context) {
EvaluateRangeResult result = evaluateChildrenThenThis(expr, context);
// NOTE: if children exist empty range return false
// !!! this is different from `returnFalseIfExistEmptyRange` !!!
expr = result.result;
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;
return evaluateChildrenThenThis(expr, context);
}
@Override