Skip to content

Commit

Permalink
[fix](intersect) fix coredump caused by intersect of nullable and not…
Browse files Browse the repository at this point in the history
… nullable children (#36401)
  • Loading branch information
jacktengg authored Jun 18, 2024
1 parent 1fb6dca commit c8ef1f5
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
13 changes: 12 additions & 1 deletion be/src/vec/exec/vset_operation_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,18 @@ void VSetOperationNode<is_intersect>::add_result_columns(RowRefListWithFlags& va
auto it = value.begin();
for (auto idx = _build_col_idx.begin(); idx != _build_col_idx.end(); ++idx) {
const auto& column = *_build_blocks[it->block_offset].get_by_position(idx->second).column;
_mutable_cols[idx->first]->insert_from(column, it->row_num);
if (_mutable_cols[idx->second]->is_nullable() xor column.is_nullable()) {
if (_mutable_cols[idx->second]->is_nullable()) {
((ColumnNullable*)(_mutable_cols[idx->second].get()))
->insert_from_not_nullable(column, it->row_num);
} else {
auto& nest_col = ((ColumnNullable&)column).get_nested_column();
_mutable_cols[idx->first]->insert_from(nest_col, it->row_num);
}

} else {
_mutable_cols[idx->first]->insert_from(column, it->row_num);
}
}
block_size++;
}
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
-- !intersect_nullable_not_nullable_1 --
c

-- !intersect_nullable_not_nullable_2 --
c

Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// 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("intersect_nullable_not_nullable") {
sql """
drop table if exists intersect_nullable_not_nullable_t1;
"""
sql """
drop table if exists intersect_nullable_not_nullable_t2;
"""
sql """
drop table if exists intersect_nullable_not_nullable_t3;
"""
sql """
drop table if exists intersect_nullable_not_nullable_t4;
"""
sql """
create table intersect_nullable_not_nullable_t1 (k1 char(16) not null) distributed by hash(k1) properties("replication_num"="1");
"""
sql """
insert into intersect_nullable_not_nullable_t1 values("a"), ("b"), ("c"), ("d"), ("e");
"""

sql """
create table intersect_nullable_not_nullable_t2 (kk0 int, kk1 char(16) not null) distributed by hash(kk0) properties("replication_num"="1");
"""
sql """
insert into intersect_nullable_not_nullable_t2 values(1, "b"), (2, "c"), (3, "d"), (4, "e");
"""

sql """
create table intersect_nullable_not_nullable_t3 (kkk1 char(16) ) distributed by hash(kkk1) properties("replication_num"="1");
"""
sql """
insert into intersect_nullable_not_nullable_t3 values("c"), ("d"), ("e");
"""

sql """
create table intersect_nullable_not_nullable_t4 (kkkk1 char(16) ) distributed by hash(kkkk1) properties("replication_num"="1");
"""
sql """
insert into intersect_nullable_not_nullable_t4 values("d"), ("e");
"""

order_qt_intersect_nullable_not_nullable_1 """
(
select * from intersect_nullable_not_nullable_t1
)
intersect
(
select distinct kk1 from intersect_nullable_not_nullable_t2
)
intersect
(
(
select * from intersect_nullable_not_nullable_t3
)
except
(
select * from intersect_nullable_not_nullable_t4
)
);
"""

order_qt_intersect_nullable_not_nullable_2 """
(
select * from intersect_nullable_not_nullable_t1
)
intersect
(
(
select * from intersect_nullable_not_nullable_t3
)
except
(
select * from intersect_nullable_not_nullable_t4
)
)
intersect
(
select distinct kk1 from intersect_nullable_not_nullable_t2
);
"""
}

0 comments on commit c8ef1f5

Please sign in to comment.