Skip to content

Commit

Permalink
Fix the bug of grout by column is null (apache#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
HappenLee committed Aug 10, 2021
1 parent 037cd40 commit 18361a3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 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 @@ -1826,4 +1826,12 @@ public boolean isContainsClass(String className) {
return false;
}

/**
* For excute expr the result is nullable
* TODO: Now only SlotRef and LiteralExpr overwrite the method, each child of Expr should
* overwrite this method to plan correct
*/
public boolean isNullable() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,8 @@ public TupleDescriptor createTupleDescriptor(Analyzer analyzer) throws AnalysisE
}

columnSet.add(colAlias);
// TODO: inlineView threat all column is nullable to make sure query results are correct
// we should judge column whether is nullable by selectItemExpr in the future
columnList.add(new Column(colAlias, selectItemExpr.getType().getPrimitiveType(), true));
columnList.add(new Column(colAlias, selectItemExpr.getType().getPrimitiveType(),
selectItemExpr.isNullable()));
}
InlineView inlineView = (view != null) ? new InlineView(view, columnList) : new InlineView(getExplicitAlias(), columnList);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,10 @@ public boolean equals(Object obj) {
}
return this.compareLiteral(((LiteralExpr) obj)) == 0;
}

@Override
public boolean isNullable() {
return this instanceof NullLiteral;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public int getSlotOffset() {
* Initializes a slot by setting its source expression information
*/
public void initFromExpr(Expr expr) {
setIsNullable(expr.isNullable());
setLabel(expr.toSql());
Preconditions.checkState(sourceExprs_.isEmpty());
setSourceExpr(expr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,9 @@ public static SlotRef read(DataInput in) throws IOException {
slotRef.readFields(in);
return slotRef;
}

@Override
public boolean isNullable() {
return desc.getIsNullable();
}
}

0 comments on commit 18361a3

Please sign in to comment.