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 Jul 13, 2021
1 parent ff3cc1f commit f93b451
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
9 changes: 9 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 @@ -1710,4 +1710,13 @@ public Expr getResultValue() throws AnalysisException {
final Expr newExpr = ExpressionFunctions.INSTANCE.evalExpr(this);
return newExpr != null ? newExpr : this;
}

/**
* 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 @@ -194,5 +194,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 @@ -218,6 +218,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 f93b451

Please sign in to comment.