Fix bug of null safe equal join (#2193)
This commit is contained in:
@ -137,13 +137,15 @@ Status HashJoinNode::prepare(RuntimeState* state) {
|
||||
_build_tuple_row_size = num_build_tuples * sizeof(Tuple*);
|
||||
|
||||
// TODO: default buckets
|
||||
const bool null_preserved = _join_op == TJoinOp::RIGHT_OUTER_JOIN
|
||||
const bool stores_nulls = _join_op == TJoinOp::RIGHT_OUTER_JOIN
|
||||
|| _join_op == TJoinOp::FULL_OUTER_JOIN
|
||||
|| _join_op == TJoinOp::RIGHT_ANTI_JOIN
|
||||
|| _join_op == TJoinOp::RIGHT_SEMI_JOIN;
|
||||
|| _join_op == TJoinOp::RIGHT_SEMI_JOIN
|
||||
|| (std::find(_is_null_safe_eq_join.begin(), _is_null_safe_eq_join.end(),
|
||||
true) != _is_null_safe_eq_join.end());
|
||||
_hash_tbl.reset(new HashTable(
|
||||
_build_expr_ctxs, _probe_expr_ctxs, _build_tuple_size,
|
||||
null_preserved, _is_null_safe_eq_join, id(), mem_tracker(), 1024));
|
||||
stores_nulls, _is_null_safe_eq_join, id(), mem_tracker(), 1024));
|
||||
|
||||
_probe_batch.reset(new RowBatch(child(0)->row_desc(), state->batch_size(), mem_tracker()));
|
||||
|
||||
|
||||
@ -42,18 +42,15 @@ const char* HashTable::_s_llvm_class_name = "class.doris::HashTable";
|
||||
|
||||
HashTable::HashTable(const vector<ExprContext*>& build_expr_ctxs,
|
||||
const vector<ExprContext*>& probe_expr_ctxs,
|
||||
int num_build_tuples, bool null_preserved,
|
||||
int num_build_tuples, bool stores_nulls,
|
||||
const std::vector<bool>& finds_nulls,
|
||||
int32_t initial_seed,
|
||||
MemTracker* mem_tracker, int64_t num_buckets) :
|
||||
_build_expr_ctxs(build_expr_ctxs),
|
||||
_probe_expr_ctxs(probe_expr_ctxs),
|
||||
_num_build_tuples(num_build_tuples),
|
||||
_null_preserved(null_preserved),
|
||||
_stores_nulls(stores_nulls),
|
||||
_finds_nulls(finds_nulls),
|
||||
_stores_nulls(null_preserved
|
||||
|| (std::find(finds_nulls.begin(), finds_nulls.end(),
|
||||
true) != finds_nulls.end())),
|
||||
_initial_seed(initial_seed),
|
||||
_node_byte_size(sizeof(Node) + sizeof(Tuple*) * _num_build_tuples),
|
||||
_num_filled_buckets(0),
|
||||
@ -186,7 +183,7 @@ bool HashTable::equals(TupleRow* build_row) {
|
||||
void* val = _build_expr_ctxs[i]->get_value(build_row);
|
||||
|
||||
if (val == NULL) {
|
||||
if (!(_null_preserved && _finds_nulls[i])) {
|
||||
if (!(_stores_nulls && _finds_nulls[i])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -386,13 +386,11 @@ private:
|
||||
|
||||
// Number of Tuple* in the build tuple row
|
||||
const int _num_build_tuples;
|
||||
// the row in hash table is preserved such as RIGHT_OUTER_JOIN
|
||||
const bool _null_preserved;
|
||||
// outer join || has null equal join should be true
|
||||
const bool _stores_nulls;
|
||||
// true: the null-safe equal '<=>' is true. The row with null shoud be judged.
|
||||
// false: the equal '=' is false. The row with null should be filtered.
|
||||
const std::vector<bool> _finds_nulls;
|
||||
// outer join || has null equal join should be true
|
||||
const bool _stores_nulls;
|
||||
|
||||
const int32_t _initial_seed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user