[fix](lateral-view) Fix some lateral view bugs (#7772)
1. Fix bug that BE may crash when input node of TableFunctionNode has non-null column 2. Fix bug that TableFunctionNode may not return all results
This commit is contained in:
@ -21,8 +21,10 @@ import org.apache.doris.analysis.Analyzer;
|
||||
import org.apache.doris.analysis.Expr;
|
||||
import org.apache.doris.analysis.LateralViewRef;
|
||||
import org.apache.doris.analysis.SelectStmt;
|
||||
import org.apache.doris.analysis.SlotDescriptor;
|
||||
import org.apache.doris.analysis.SlotId;
|
||||
import org.apache.doris.analysis.SlotRef;
|
||||
import org.apache.doris.analysis.TupleDescriptor;
|
||||
import org.apache.doris.analysis.TupleId;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.UserException;
|
||||
@ -107,6 +109,20 @@ public class TableFunctionNode extends PlanNode {
|
||||
for (SlotRef slotRef : outputSlotRef) {
|
||||
outputSlotIds.add(slotRef.getSlotId());
|
||||
}
|
||||
|
||||
// For all other slots from input node which are not in outputSlotIds,
|
||||
// set them as nullable, so that we can set them to null in TableFunctionNode
|
||||
// TODO(cmy): This should be done with a ProjectionNode
|
||||
PlanNode inputNode = getChild(0);
|
||||
List<TupleId> inputTupleIds = inputNode.getTupleIds();
|
||||
for (TupleId tupleId : inputTupleIds) {
|
||||
TupleDescriptor td = analyzer.getTupleDesc(tupleId);
|
||||
for (SlotDescriptor sd : td.getSlots()) {
|
||||
if (!outputSlotIds.contains(sd.getId())) {
|
||||
sd.setIsNullable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -179,3 +195,4 @@ public class TableFunctionNode extends PlanNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user