You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/04/18 11:57:55 UTC
[incubator-doris] 16/17: [fix](table-function) Fix bug of table function with outer join cause nullptr of tuple (#9041)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 8ca12ddadd247dd5027fd65cfc18f01654970308
Author: HappenLee <ha...@hotmail.com>
AuthorDate: Mon Apr 18 19:35:26 2022 +0800
[fix](table-function) Fix bug of table function with outer join cause nullptr of tuple (#9041)
---
be/src/exec/table_function_node.cpp | 36 +++---
.../data/table_function/explose_json_array.out | 136 ---------------------
2 files changed, 21 insertions(+), 151 deletions(-)
diff --git a/be/src/exec/table_function_node.cpp b/be/src/exec/table_function_node.cpp
index 126e397c9a..1a06c0cb30 100644
--- a/be/src/exec/table_function_node.cpp
+++ b/be/src/exec/table_function_node.cpp
@@ -271,23 +271,29 @@ 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())
- && 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());
+ // The child tuple is nullptr, only when the child tuple is from outer join. so we directly set
+ // parent_tuple have same tuple_idx nullptr to mock the behavior
+ if (child_tuple != nullptr) {
+ // 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())
+ && 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());
+ }
}
+ parent_tuple_row->set_tuple(tuple_idx, tuple_ptr);
+ } else {
+ parent_tuple_row->set_tuple(tuple_idx, nullptr);
}
- parent_tuple_row->set_tuple(tuple_idx, tuple_ptr);
tuple_ptr = reinterpret_cast<Tuple*>(reinterpret_cast<uint8_t*>(tuple_ptr) +
parent_tuple_desc->byte_size());
}
diff --git a/regression-test/data/table_function/explose_json_array.out b/regression-test/data/table_function/explose_json_array.out
deleted file mode 100644
index 43521562af..0000000000
--- a/regression-test/data/table_function/explose_json_array.out
+++ /dev/null
@@ -1,136 +0,0 @@
--- This file is automatically generated. You should know what you did if you want to edit this
--- !explose_json_array --
-100 John 30 1 Street 1 40 30
-100 John 30 1 Street 1 80 30
-100 John 30 1 Street 1 40 60
-100 John 30 1 Street 1 80 60
-200 Mary \N 1 Street 2 40 30
-200 Mary \N 1 Street 2 80 30
-200 Mary \N 1 Street 2 40 60
-200 Mary \N 1 Street 2 80 60
-300 Mike 80 3 Street 3 40 30
-300 Mike 80 3 Street 3 80 30
-300 Mike 80 3 Street 3 40 60
-300 Mike 80 3 Street 3 80 60
-400 Dan 50 4 Street 4 40 30
-400 Dan 50 4 Street 4 80 30
-400 Dan 50 4 Street 4 40 60
-400 Dan 50 4 Street 4 80 60
-
--- !explose_json_array --
-30 8
-60 8
-
--- !explose_json_array --
-100 John 30 1 Street 1 \N
-200 Mary \N 1 Street 2 \N
-300 Mike 80 3 Street 3 \N
-400 Dan 50 4 Street 4 \N
-
--- !explose_json_array --
-100 John 30 1 Street 1 1.23 1
-100 John 30 1 Street 1 22.214 1
-100 John 30 1 Street 1 214.1 1
-100 John 30 1 Street 1 1.23 3
-100 John 30 1 Street 1 22.214 3
-100 John 30 1 Street 1 214.1 3
-100 John 30 1 Street 1 1.23 b
-100 John 30 1 Street 1 22.214 b
-100 John 30 1 Street 1 214.1 b
-200 Mary \N 1 Street 2 1.23 1
-200 Mary \N 1 Street 2 22.214 1
-200 Mary \N 1 Street 2 214.1 1
-200 Mary \N 1 Street 2 1.23 3
-200 Mary \N 1 Street 2 22.214 3
-200 Mary \N 1 Street 2 214.1 3
-200 Mary \N 1 Street 2 1.23 b
-200 Mary \N 1 Street 2 22.214 b
-200 Mary \N 1 Street 2 214.1 b
-300 Mike 80 3 Street 3 1.23 1
-300 Mike 80 3 Street 3 22.214 1
-300 Mike 80 3 Street 3 214.1 1
-300 Mike 80 3 Street 3 1.23 3
-300 Mike 80 3 Street 3 22.214 3
-300 Mike 80 3 Street 3 214.1 3
-300 Mike 80 3 Street 3 1.23 b
-300 Mike 80 3 Street 3 22.214 b
-300 Mike 80 3 Street 3 214.1 b
-400 Dan 50 4 Street 4 1.23 1
-400 Dan 50 4 Street 4 22.214 1
-400 Dan 50 4 Street 4 214.1 1
-400 Dan 50 4 Street 4 1.23 3
-400 Dan 50 4 Street 4 22.214 3
-400 Dan 50 4 Street 4 214.1 3
-400 Dan 50 4 Street 4 1.23 b
-400 Dan 50 4 Street 4 22.214 b
-400 Dan 50 4 Street 4 214.1 b
-
--- !explose_json_array --
-true
-
--- !explose_json_array --
-100 John 30 1 Street 1 40 30
-100 John 30 1 Street 1 80 30
-100 John 30 1 Street 1 40 60
-100 John 30 1 Street 1 80 60
-200 Mary \N 1 Street 2 40 30
-200 Mary \N 1 Street 2 80 30
-200 Mary \N 1 Street 2 40 60
-200 Mary \N 1 Street 2 80 60
-300 Mike 80 3 Street 3 40 30
-300 Mike 80 3 Street 3 80 30
-300 Mike 80 3 Street 3 40 60
-300 Mike 80 3 Street 3 80 60
-400 Dan 50 4 Street 4 40 30
-400 Dan 50 4 Street 4 80 30
-400 Dan 50 4 Street 4 40 60
-400 Dan 50 4 Street 4 80 60
-
--- !explose_json_array --
-30 8
-60 8
-
--- !explose_json_array --
-100 John 30 1 Street 1 \N
-200 Mary \N 1 Street 2 \N
-300 Mike 80 3 Street 3 \N
-400 Dan 50 4 Street 4 \N
-
--- !explose_json_array --
-100 John 30 1 Street 1 1.23 1
-100 John 30 1 Street 1 22.214 1
-100 John 30 1 Street 1 214.1 1
-100 John 30 1 Street 1 1.23 3
-100 John 30 1 Street 1 22.214 3
-100 John 30 1 Street 1 214.1 3
-100 John 30 1 Street 1 1.23 b
-100 John 30 1 Street 1 22.214 b
-100 John 30 1 Street 1 214.1 b
-200 Mary \N 1 Street 2 1.23 1
-200 Mary \N 1 Street 2 22.214 1
-200 Mary \N 1 Street 2 214.1 1
-200 Mary \N 1 Street 2 1.23 3
-200 Mary \N 1 Street 2 22.214 3
-200 Mary \N 1 Street 2 214.1 3
-200 Mary \N 1 Street 2 1.23 b
-200 Mary \N 1 Street 2 22.214 b
-200 Mary \N 1 Street 2 214.1 b
-300 Mike 80 3 Street 3 1.23 1
-300 Mike 80 3 Street 3 22.214 1
-300 Mike 80 3 Street 3 214.1 1
-300 Mike 80 3 Street 3 1.23 3
-300 Mike 80 3 Street 3 22.214 3
-300 Mike 80 3 Street 3 214.1 3
-300 Mike 80 3 Street 3 1.23 b
-300 Mike 80 3 Street 3 22.214 b
-300 Mike 80 3 Street 3 214.1 b
-400 Dan 50 4 Street 4 1.23 1
-400 Dan 50 4 Street 4 22.214 1
-400 Dan 50 4 Street 4 214.1 1
-400 Dan 50 4 Street 4 1.23 3
-400 Dan 50 4 Street 4 22.214 3
-400 Dan 50 4 Street 4 214.1 3
-400 Dan 50 4 Street 4 1.23 b
-400 Dan 50 4 Street 4 22.214 b
-400 Dan 50 4 Street 4 214.1 b
-
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org