Skip to content

Commit

Permalink
[BUG] Fix Left Semi Join Got a Wrong Result (apache#6379)
Browse files Browse the repository at this point in the history
```
SELECT count(distinct products_id) FROM a_table as a WHERE 1=1 AND products_id in ( SELECT products_id from b_table );
```
Because hash table construction errors may lead to unstable results
  • Loading branch information
stdpain authored Aug 7, 2021
1 parent 36fe112 commit 3519a4f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions be/src/exec/hash_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
namespace doris {

inline bool HashTable::emplace_key(TupleRow* row, TupleRow** dest_addr) {
if (_num_filled_buckets > _num_buckets_till_resize) {
resize_buckets(_num_buckets * 2);
}
if (_current_used == _current_capacity) {
grow_node_array();
}

bool has_nulls = eval_build_row(row);

if (!_stores_nulls && has_nulls) {
Expand Down Expand Up @@ -52,14 +59,6 @@ inline bool HashTable::emplace_key(TupleRow* row, TupleRow** dest_addr) {
node = last_node;
}
if (will_insert) {
if (_num_filled_buckets > _num_buckets_till_resize) {
resize_buckets(_num_buckets * 2);
// real bucket_id will modify after resize buckets
bucket_idx = hash & (_num_buckets - 1);
}
if (_current_used == _current_capacity) {
grow_node_array();
}
Node* alloc_node =
reinterpret_cast<Node*>(_current_nodes + _node_byte_size * _current_used++);
++_num_nodes;
Expand Down

0 comments on commit 3519a4f

Please sign in to comment.