Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public Expr getResultValue(boolean forPushDownPredicatesToView) throws AnalysisE
// 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -124,7 +125,10 @@ public Expr apply(Expr expr, Analyzer analyzer, ExprRewriter.ClauseType clauseTy
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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,10 @@ suite("literal_view_test") {
sql "select * from (select null as top) t where top = 5"
result ([])
}

sql """set enable_nereids_planner=false;"""
explain {
sql """ select c.* from ( select a.*, '' x from test_insert a left join test_insert b on true ) c where c.x is null; """
notContains("VEMPTYSET")
}
}