diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java index f99bcacf441454..3064065539ea01 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java @@ -799,8 +799,8 @@ public static BinaryPredicate read(DataInput in) throws IOException { } @Override - public Expr getResultValue(boolean inView) throws AnalysisException { - recursiveResetChildrenResult(inView); + public Expr getResultValue(boolean forPushDownPredicatesToView) throws AnalysisException { + recursiveResetChildrenResult(forPushDownPredicatesToView); final Expr leftChildValue = getChild(0); final Expr rightChildValue = getChild(1); if (!(leftChildValue instanceof LiteralExpr) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java index bf5c75c58f02ea..bf8f7930e00e62 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java @@ -399,8 +399,8 @@ public boolean canHashPartition() { } @Override - public Expr getResultValue(boolean inView) throws AnalysisException { - recursiveResetChildrenResult(inView); + public Expr getResultValue(boolean forPushDownPredicatesToView) throws AnalysisException { + recursiveResetChildrenResult(forPushDownPredicatesToView); final Expr value = children.get(0); if (!(value instanceof LiteralExpr)) { return this; diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CompoundPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CompoundPredicate.java index e20ec98b756b36..78e28da6ed9c51 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CompoundPredicate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CompoundPredicate.java @@ -230,8 +230,8 @@ public static boolean isOr(Expr expr) { } @Override - public Expr getResultValue(boolean inView) throws AnalysisException { - recursiveResetChildrenResult(inView); + public Expr getResultValue(boolean forPushDownPredicatesToView) throws AnalysisException { + recursiveResetChildrenResult(forPushDownPredicatesToView); boolean compoundResult = false; if (op == Operator.NOT) { final Expr childValue = getChild(0); diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java index fe03afd02c3a2e..4b7d2971d95b26 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java @@ -2189,10 +2189,10 @@ public boolean supportSerializable() { } - protected void recursiveResetChildrenResult(boolean inView) throws AnalysisException { + protected void recursiveResetChildrenResult(boolean forPushDownPredicatesToView) throws AnalysisException { for (int i = 0; i < children.size(); i++) { final Expr child = children.get(i); - final Expr newChild = child.getResultValue(inView); + final Expr newChild = child.getResultValue(forPushDownPredicatesToView); if (newChild != child) { setChild(i, newChild); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/InPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/InPredicate.java index c110b2e6ea3321..3a08359a75ad99 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/InPredicate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/InPredicate.java @@ -308,8 +308,8 @@ public String toString() { } @Override - public Expr getResultValue(boolean inView) throws AnalysisException { - recursiveResetChildrenResult(inView); + public Expr getResultValue(boolean forPushDownPredicatesToView) throws AnalysisException { + recursiveResetChildrenResult(forPushDownPredicatesToView); final Expr leftChildValue = getChild(0); if (!(leftChildValue instanceof LiteralExpr) || !isLiteralChildren()) { return this; diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/IsNullPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/IsNullPredicate.java index 087b4a7c399af0..bf81cb48100d02 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/IsNullPredicate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/IsNullPredicate.java @@ -155,8 +155,10 @@ public boolean isNullable() { * fix issue 6390 */ @Override - public Expr getResultValue(boolean inView) throws AnalysisException { - recursiveResetChildrenResult(inView); + public Expr getResultValue(boolean forPushDownPredicatesToView) throws AnalysisException { + // Don't push down predicate to view for is null predicate because the value can contain null + // after outer join + recursiveResetChildrenResult(!forPushDownPredicatesToView); final Expr childValue = getChild(0); if (!(childValue instanceof LiteralExpr)) { return this; diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java index 944c398de9a3a5..9b664d8b42a60d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java @@ -613,8 +613,8 @@ public boolean matchExprs(List exprs, SelectStmt stmt, boolean ignoreAlias } @Override - public Expr getResultValue(boolean foldSlot) throws AnalysisException { - if (!foldSlot) { + public Expr getResultValue(boolean forPushDownPredicatesToView) throws AnalysisException { + if (!forPushDownPredicatesToView) { return this; } if (!isConstant() || desc == null) { @@ -626,7 +626,7 @@ public Expr getResultValue(boolean foldSlot) throws AnalysisException { } Expr expr = exprs.get(0); if (expr instanceof SlotRef) { - return expr.getResultValue(foldSlot); + return expr.getResultValue(forPushDownPredicatesToView); } if (expr.isConstant()) { return expr; diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/VariableExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/VariableExpr.java index 8e657d6418dacf..093a7861173c0a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/VariableExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/VariableExpr.java @@ -137,7 +137,7 @@ public Expr getLiteralExpr() { } @Override - public Expr getResultValue(boolean inView) throws AnalysisException { + public Expr getResultValue(boolean forPushDownPredicatesToView) throws AnalysisException { if (!Strings.isNullOrEmpty(name) && VariableVarConverters.hasConverter(name)) { // Return the string type here so that it can correctly match the subsequent function signature. // And we also set `beConverted` to session variable name in StringLiteral, so that it can be cast back diff --git a/regression-test/data/query_p0/literal_view/lietral_test.out b/regression-test/data/query_p0/literal_view/lietral_test.out index daa91d59cd1c1f..0d9abd8bc35d12 100644 --- a/regression-test/data/query_p0/literal_view/lietral_test.out +++ b/regression-test/data/query_p0/literal_view/lietral_test.out @@ -1,5 +1,10 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !sql -- +-- !left -- +3 flink 20 \N +1 doris 10 \N +2 spark 2 \N + -- !sql1 -- diff --git a/regression-test/suites/query_p0/literal_view/lietral_test.groovy b/regression-test/suites/query_p0/literal_view/lietral_test.groovy index 0c5f8bcec0019e..8ebfd1cc233f1a 100644 --- a/regression-test/suites/query_p0/literal_view/lietral_test.groovy +++ b/regression-test/suites/query_p0/literal_view/lietral_test.groovy @@ -106,7 +106,16 @@ suite("literal_view_test") { insert into test_insert values (1,'doris',10),(2,'spark',2),(3,'flink',20); """ - qt_sql1 """ + sql "set enable_nereids_planner=false" + order_qt_left """select * + from test_insert + left join (select 1 as v1) t1 + on false + where t1.v1 is null + """ + sql "set enable_nereids_planner=true" + + order_qt_sql1 """ select id, name from ( select '123' as id,