[fix](planner)isnull predicate can't be safely constant folded in inlineview (#25377)
disable is null predicate constant fold rule for inline view consider sql select c.* from ( select a.*, b.x from test_insert a left join (select 'some_const_str' x from test_insert) b on true ) c where c.x is null; when push “c.x is null” into c, after folding constant rule, it will get empty result. Because x is 'some_const_str' and "x is null" will be evaluated to false. This is wrong.
This commit is contained in:
@ -160,7 +160,7 @@ public class IsNullPredicate extends Predicate {
|
||||
// after outer join
|
||||
recursiveResetChildrenResult(!forPushDownPredicatesToView);
|
||||
final Expr childValue = getChild(0);
|
||||
if (!(childValue instanceof LiteralExpr)) {
|
||||
if (forPushDownPredicatesToView || !(childValue instanceof LiteralExpr)) {
|
||||
return this;
|
||||
}
|
||||
return childValue instanceof NullLiteral ? new BoolLiteral(!isNotNull) : new BoolLiteral(isNotNull);
|
||||
|
||||
@ -29,6 +29,7 @@ import org.apache.doris.analysis.Expr;
|
||||
import org.apache.doris.analysis.InformationFunction;
|
||||
import org.apache.doris.analysis.LiteralExpr;
|
||||
import org.apache.doris.analysis.NullLiteral;
|
||||
import org.apache.doris.analysis.SlotRef;
|
||||
import org.apache.doris.analysis.VariableExpr;
|
||||
import org.apache.doris.catalog.Env;
|
||||
import org.apache.doris.catalog.PrimitiveType;
|
||||
@ -124,7 +125,10 @@ public class FoldConstantsRule implements ExprRewriteRule {
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
return expr.getResultValue(false);
|
||||
// it may be wrong to fold constant value in inline view
|
||||
// so pass the info to getResultValue method to let predicate itself
|
||||
// to decide if it can fold constant value safely
|
||||
return expr.getResultValue(expr instanceof SlotRef ? false : analyzer.isInlineViewAnalyzer());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user