Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pick2.0](Planner): don't push down isNull predicate into view (#26288) #26773

Merged
merged 1 commit into from
Nov 12, 2023
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 @@ -720,8 +720,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
Original file line number Diff line number Diff line change
Expand Up @@ -2177,10 +2177,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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ 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 (inView || !(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 @@ -607,8 +607,8 @@ public boolean matchExprs(List<Expr> 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) {
Expand All @@ -620,7 +620,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions regression-test/data/query_p0/literal_view/lietral_test.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --

-- !left --
1 doris 10 \N
2 spark 2 \N
3 flink 20 \N

-- !sql1 --

Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ suite("literal_view_test") {
insert into test_insert values (1,'doris',10),(2,'spark',2),(3,'flink',20);
"""

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"

qt_sql1 """
select id, name
from (
Expand Down
Loading