[fix](null safe equal join) fix coredump if both sides of the conjunct is not nullable #36263 (#37073)

This commit is contained in:
TengJianPing
2024-07-02 11:01:55 +08:00
committed by GitHub
parent 011f203d71
commit 6789f5bc80
4 changed files with 360 additions and 4 deletions

View File

@ -486,8 +486,14 @@ Status HashJoinBuildSinkOperatorX::init(const TPlanNode& tnode, RuntimeState* st
const auto vexpr = _build_expr_ctxs.back()->root();
/// null safe equal means null = null is true, the operator in SQL should be: <=>.
const bool is_null_safe_equal = eq_join_conjunct.__isset.opcode &&
eq_join_conjunct.opcode == TExprOpcode::EQ_FOR_NULL;
const bool is_null_safe_equal =
eq_join_conjunct.__isset.opcode &&
(eq_join_conjunct.opcode == TExprOpcode::EQ_FOR_NULL) &&
// For a null safe equal join, FE may generate a plan that
// both sides of the conjuct are not nullable, we just treat it
// as a normal equal join conjunct.
(eq_join_conjunct.right.nodes[0].is_nullable ||
eq_join_conjunct.left.nodes[0].is_nullable);
const bool should_convert_to_nullable = is_null_safe_equal &&
!eq_join_conjunct.right.nodes[0].is_nullable &&

View File

@ -540,13 +540,17 @@ Status HashJoinProbeOperatorX::init(const TPlanNode& tnode, RuntimeState* state)
RETURN_IF_ERROR(vectorized::VExpr::create_expr_tree(eq_join_conjunct.left, ctx));
_probe_expr_ctxs.push_back(ctx);
bool null_aware = eq_join_conjunct.__isset.opcode &&
eq_join_conjunct.opcode == TExprOpcode::EQ_FOR_NULL;
eq_join_conjunct.opcode == TExprOpcode::EQ_FOR_NULL &&
(eq_join_conjunct.right.nodes[0].is_nullable ||
eq_join_conjunct.left.nodes[0].is_nullable);
probe_not_ignore_null[conjuncts_index] =
null_aware ||
(_probe_expr_ctxs.back()->root()->is_nullable() && probe_dispose_null);
conjuncts_index++;
const bool is_null_safe_equal = eq_join_conjunct.__isset.opcode &&
eq_join_conjunct.opcode == TExprOpcode::EQ_FOR_NULL;
(eq_join_conjunct.opcode == TExprOpcode::EQ_FOR_NULL) &&
(eq_join_conjunct.right.nodes[0].is_nullable ||
eq_join_conjunct.left.nodes[0].is_nullable);
/// If it's right anti join,
/// we should convert the probe to nullable if the build side is nullable.

View File

@ -0,0 +1,5 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !rqg12257 --
-- !rqg12257_2 --

File diff suppressed because one or more lines are too long