Skip to content

Commit

Permalink
[BugFix] Fix union isnullable error (backport #32426) (#42617)
Browse files Browse the repository at this point in the history
Signed-off-by: Seaven <[email protected]>
  • Loading branch information
Seaven authored Mar 14, 2024
1 parent 3921c40 commit 885a678
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2502,9 +2502,16 @@ private PlanFragment buildSetOperation(OptExpression optExpr, ExecPlan context,
// reset column is nullable, for handle union select xx join select xxx...
setOperationNode.setHasNullableGenerateChild();
List<Expr> setOutputList = Lists.newArrayList();
for (ColumnRefOperator columnRefOperator : setOperation.getOutputColumnRefOp()) {
for (int index = 0; index < setOperation.getOutputColumnRefOp().size(); index++) {
ColumnRefOperator columnRefOperator = setOperation.getOutputColumnRefOp().get(index);
SlotDescriptor slotDesc = context.getDescTbl().getSlotDesc(new SlotId(columnRefOperator.getId()));
slotDesc.setIsNullable(slotDesc.getIsNullable() | setOperationNode.isHasNullableGenerateChild());
boolean isNullable = slotDesc.getIsNullable() | setOperationNode.isHasNullableGenerateChild();
for (List<ColumnRefOperator> childOutputColumn : setOperation.getChildOutputColumns()) {
ColumnRefOperator childRef = childOutputColumn.get(index);
Expr childExpr = ScalarOperatorToExpr.buildExecExpression(childRef, formatterContext);
isNullable |= childExpr.isNullable();
}
slotDesc.setIsNullable(isNullable);
setOutputList.add(new SlotRef(String.valueOf(columnRefOperator.getId()), slotDesc));
}
setOperationTuple.computeMemLayout();
Expand Down

0 comments on commit 885a678

Please sign in to comment.