From 83b959833c6a2ca2d22c23ed546411597e0f6a0a Mon Sep 17 00:00:00 2001 From: BiteTheDDDDt Date: Fri, 8 Sep 2023 17:17:55 +0800 Subject: [PATCH] fix core dump on short_circuit_for_probe_and_additional_data --- be/src/vec/exec/join/vhash_join_node.cpp | 5 +++++ be/src/vec/exec/join/vjoin_node_base.h | 11 +++++++++++ be/src/vec/exec/join/vnested_loop_join_node.cpp | 12 ------------ be/src/vec/exec/join/vnested_loop_join_node.h | 2 -- be/src/vec/functions/if.cpp | 2 +- be/src/vec/utils/util.hpp | 8 +++++++- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/be/src/vec/exec/join/vhash_join_node.cpp b/be/src/vec/exec/join/vhash_join_node.cpp index 40258339044b5b..dbe4b7b67d0cce 100644 --- a/be/src/vec/exec/join/vhash_join_node.cpp +++ b/be/src/vec/exec/join/vhash_join_node.cpp @@ -484,6 +484,11 @@ Status HashJoinNode::pull(doris::RuntimeState* state, vectorized::Block* output_ _right_table_column_names[i]}); } + if (_is_outer_join) { + _resize_fill_tuple_is_null_column(block_rows, 1, 1); + _add_tuple_is_null_column(&temp_block); + } + { SCOPED_TIMER(_join_filter_timer); RETURN_IF_ERROR( diff --git a/be/src/vec/exec/join/vjoin_node_base.h b/be/src/vec/exec/join/vjoin_node_base.h index 234374e3c0e09b..7c3288f3cb3ac8 100644 --- a/be/src/vec/exec/join/vjoin_node_base.h +++ b/be/src/vec/exec/join/vjoin_node_base.h @@ -77,6 +77,17 @@ class VJoinNodeBase : public ExecNode { [[nodiscard]] bool can_terminate_early() override { return _short_circuit_for_probe; } protected: + void _resize_fill_tuple_is_null_column(size_t new_size, int left_flag, int right_flag) { + if (_is_outer_join) { + reinterpret_cast(_tuple_is_null_left_flag_column.get()) + ->get_data() + .resize_fill(new_size, left_flag); + reinterpret_cast(_tuple_is_null_right_flag_column.get()) + ->get_data() + .resize_fill(new_size, right_flag); + } + } + // Construct the intermediate blocks to store the results from join operation. void _construct_mutable_join_block(); // Convert the intermediate blocks to the final result. For example, if the block from probe diff --git a/be/src/vec/exec/join/vnested_loop_join_node.cpp b/be/src/vec/exec/join/vnested_loop_join_node.cpp index 82fecf5793b3dd..6fb66cad92b82b 100644 --- a/be/src/vec/exec/join/vnested_loop_join_node.cpp +++ b/be/src/vec/exec/join/vnested_loop_join_node.cpp @@ -372,18 +372,6 @@ void VNestedLoopJoinNode::_update_additional_flags(Block* block) { } } -void VNestedLoopJoinNode::_resize_fill_tuple_is_null_column(size_t new_size, int left_flag, - int right_flag) { - if (_is_outer_join) { - reinterpret_cast(_tuple_is_null_left_flag_column.get()) - ->get_data() - .resize_fill(new_size, left_flag); - reinterpret_cast(_tuple_is_null_right_flag_column.get()) - ->get_data() - .resize_fill(new_size, right_flag); - } -} - void VNestedLoopJoinNode::_add_tuple_is_null_column(Block* block) { if (_is_outer_join) { auto p0 = _tuple_is_null_left_flag_column->assume_mutable(); diff --git a/be/src/vec/exec/join/vnested_loop_join_node.h b/be/src/vec/exec/join/vnested_loop_join_node.h index 7decf4fd37e5f0..11add2dbc089d5 100644 --- a/be/src/vec/exec/join/vnested_loop_join_node.h +++ b/be/src/vec/exec/join/vnested_loop_join_node.h @@ -225,8 +225,6 @@ class VNestedLoopJoinNode final : public VJoinNodeBase { Status _fresh_left_block(RuntimeState* state); - void _resize_fill_tuple_is_null_column(size_t new_size, int left_flag, int right_flag); - // add tuple is null flag column to Block for filter conjunct and output expr void _update_additional_flags(Block* block); diff --git a/be/src/vec/functions/if.cpp b/be/src/vec/functions/if.cpp index 77f1c0ae53b20c..10069404b0ffa0 100644 --- a/be/src/vec/functions/if.cpp +++ b/be/src/vec/functions/if.cpp @@ -291,7 +291,7 @@ class FunctionIf : public IFunction { const ColumnWithTypeAndName& arg_cond, const ColumnWithTypeAndName& arg_then, const ColumnWithTypeAndName& arg_else, size_t result, - size_t input_rows_count, Status& status) { + size_t input_rows_count, Status& status) const { bool then_is_null = arg_then.column->only_null(); bool else_is_null = arg_else.column->only_null(); diff --git a/be/src/vec/utils/util.hpp b/be/src/vec/utils/util.hpp index 440bbff1538320..e3755ce32379fb 100644 --- a/be/src/vec/utils/util.hpp +++ b/be/src/vec/utils/util.hpp @@ -135,7 +135,13 @@ class VectorizedUtils { static bool all_arguments_are_constant(const Block& block, const ColumnNumbers& args) { for (const auto& arg : args) { - if (!is_column_const(*block.get_by_position(arg).column)) { + auto column = block.get_by_position(arg).column; + if (!column) { + throw Exception( + ErrorCode::INTERNAL_ERROR, "input column is nullptr, column={}, block={}", + block.get_by_position(arg).dump_structure(), block.dump_structure()); + } + if (!is_column_const(*column)) { return false; } }