Skip to content

Commit

Permalink
add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
starocean999 committed Oct 26, 2022
1 parent de13cf0 commit 7664d41
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 5 deletions.
10 changes: 5 additions & 5 deletions be/src/vec/exec/join/vhash_join_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ Status ProcessHashTableProbe<JoinOpType, ignore_null>::do_process(HashTableType&
_build_block_rows.emplace_back(-1);
}
++current_offset;
}
else {
} else {
_items_counts[probe_index++] = (uint32_t)0;
}
all_match_one = false;
Expand Down Expand Up @@ -487,7 +486,7 @@ Status ProcessHashTableProbe<JoinOpType, ignore_null>::do_process_with_other_joi
using Mapped = typename HashTableType::Mapped;
if constexpr (std::is_same_v<Mapped, RowRefListWithFlags>) {
constexpr auto probe_all = JoinOpType::value == TJoinOp::LEFT_OUTER_JOIN ||
JoinOpType::value == TJoinOp::FULL_OUTER_JOIN;
JoinOpType::value == TJoinOp::FULL_OUTER_JOIN;
KeyGetter key_getter(probe_raw_ptrs, _join_node->_probe_key_sz, nullptr);

int right_col_idx = _join_node->_left_table_data_types.size();
Expand All @@ -512,6 +511,8 @@ Status ProcessHashTableProbe<JoinOpType, ignore_null>::do_process_with_other_joi
if ((*null_map)[probe_index]) {
if constexpr (probe_all) {
_items_counts[probe_index++] = (uint32_t)1;
same_to_prev.emplace_back(false);
visited_map.emplace_back(nullptr);
// only full outer / left outer need insert the data of right table
if (LIKELY(current_offset < _build_block_rows.size())) {
_build_block_offsets[current_offset] = -1;
Expand All @@ -521,8 +522,7 @@ Status ProcessHashTableProbe<JoinOpType, ignore_null>::do_process_with_other_joi
_build_block_rows.emplace_back(-1);
}
++current_offset;
}
else {
} else {
_items_counts[probe_index++] = (uint32_t)0;
}
all_match_one = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select1 --
2

-- !select2 --
2

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

suite("test_outer_join_with_null_value") {
sql """
drop table if exists outer_table_a;
"""

sql """
drop table if exists outer_table_b;
"""

sql """
create table outer_table_a
(
PROJECT_ID VARCHAR(32) not null,
SO_NO VARCHAR(32) not null,
ORG_ID VARCHAR(32) not null
)ENGINE = OLAP
DUPLICATE KEY(PROJECT_ID)
DISTRIBUTED BY HASH(PROJECT_ID) BUCKETS 30
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""

sql """
create table outer_table_b
(
PROJECT_ID VARCHAR(32) not null,
SO_NO VARCHAR(32),
ORG_ID VARCHAR(32) not null
)ENGINE = OLAP
DUPLICATE KEY(PROJECT_ID)
DISTRIBUTED BY HASH(PROJECT_ID) BUCKETS 30
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""

sql """
insert into outer_table_a values('1','1','1');
"""

sql """
insert into outer_table_b values('1','1','1'),('1',null,'1');
"""

qt_select1 """
select
count(*)
FROM
outer_table_b WSA
LEFT JOIN outer_table_a WBWD ON WBWD.ORG_ID = WSA.ORG_ID
AND WBWD.PROJECT_ID = WSA.PROJECT_ID
AND WBWD.SO_NO = WSA.SO_NO;
"""

qt_select2 """
select
count(*)
FROM
outer_table_b WSA
LEFT JOIN outer_table_a WBWD ON WBWD.ORG_ID = WSA.ORG_ID
AND WBWD.PROJECT_ID = WSA.PROJECT_ID
AND WBWD.SO_NO = WSA.SO_NO
AND WBWD.SO_NO >= WSA.SO_NO;
"""

sql """
drop table if exists outer_table_a;
"""

sql """
drop table if exists outer_table_b;
"""
}

0 comments on commit 7664d41

Please sign in to comment.