[fix](table-function) Fixed unreasonable nullable conversion (#8818)

This commit is contained in:
HappenLee
2022-04-03 11:02:35 +08:00
committed by GitHub
parent a8417e6c8b
commit 33736e45fa
2 changed files with 6 additions and 21 deletions

View File

@ -269,20 +269,21 @@ Status TableFunctionNode::get_next(RuntimeState* state, RowBatch* row_batch, boo
Tuple* child_tuple = _cur_child_tuple_row->get_tuple(
child_rowdesc.get_tuple_idx(child_tuple_desc->id()));
// copy the child tuple to parent_tuple
memcpy(tuple_ptr, child_tuple, parent_tuple_desc->byte_size());
// only deep copy the child slot if it is selected and is var len (Eg: string, bitmap, hll)
for (int j = 0; j < _child_slot_sizes[i]; ++j) {
SlotDescriptor* child_slot_desc = child_tuple_desc->slots()[j];
SlotDescriptor* parent_slot_desc = parent_tuple_desc->slots()[j];
if (_output_slot_ids[parent_slot_desc->id()] &&
!child_tuple->is_null(child_slot_desc->null_indicator_offset())) {
// only write child slot if it is selected and not null.
!child_tuple->is_null(child_slot_desc->null_indicator_offset())
&& child_slot_desc->type().is_string_type()) {
void* dest_slot = tuple_ptr->get_slot(parent_slot_desc->tuple_offset());
RawValue::write(child_tuple->get_slot(child_slot_desc->tuple_offset()),
dest_slot, parent_slot_desc->type(),
row_batch->tuple_data_pool());
tuple_ptr->set_not_null(parent_slot_desc->null_indicator_offset());
} else {
tuple_ptr->set_null(parent_slot_desc->null_indicator_offset());
}
}
parent_tuple_row->set_tuple(tuple_idx, tuple_ptr);

View File

@ -21,10 +21,8 @@ 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;
@ -110,20 +108,6 @@ 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