Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions be/src/vec/columns/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ class IColumn : public COW<IColumn> {
/// It's a special kind of column, that contain single value, but is not a ColumnConst.
virtual bool is_dummy() const { return false; }

virtual bool is_exclusive() const { return use_count() == 1; }

/// Clear data of column, just like vector clear
virtual void clear() {}

Expand Down
5 changes: 5 additions & 0 deletions be/src/vec/columns/column_nullable.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ class ColumnNullable final : public COWHelper<IColumn, ColumnNullable> {
bool is_column_array() const override { return get_nested_column().is_column_array(); }
bool is_fixed_and_contiguous() const override { return false; }
bool values_have_fixed_size() const override { return nested_column->values_have_fixed_size(); }

bool is_exclusive() const override {
return IColumn::is_exclusive() && nested_column->is_exclusive() && null_map->is_exclusive();
}

size_t size_of_value_if_fixed() const override {
return null_map->size_of_value_if_fixed() + nested_column->size_of_value_if_fixed();
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/core/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ void Block::filter_block_internal(Block* block, const std::vector<uint32_t>& col
for (auto& col : columns_to_filter) {
auto& column = block->get_by_position(col).column;
if (column->size() != count) {
if (column->use_count() == 1) {
if (column->is_exclusive()) {
const auto result_size = column->assume_mutable()->filter(filter);
CHECK_EQ(result_size, count);
} else {
Expand Down
5 changes: 5 additions & 0 deletions regression-test/data/correctness_p0/test_null_predicate.out
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,8 @@
-- !select14 --
13

-- !select15 --
1 \N abc
3 \N ccc
5 \N eeee

30 changes: 30 additions & 0 deletions regression-test/suites/correctness_p0/test_null_predicate.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,34 @@ suite("test_null_predicate") {
qt_select12 """ select id, name from ${tableName} where id < 110 or name is not null order by id, name; """
qt_select13 """ select id, name from ${tableName} where id > 109 or name is not null order by id, name; """
qt_select14 """ select count(1) from ${tableName} where name is not null; """

sql """ DROP TABLE IF EXISTS test_null_predicate2 """
// Here, create a table and make the "value" column nullable before the "name" column.
// Via: https://github.com/apache/doris/issues/17462
sql """
CREATE TABLE IF NOT EXISTS test_null_predicate2 (
`id` INT,
`value` double NULL,
`name` varchar(30)
) ENGINE=OLAP
DUPLICATE KEY(`id`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "V2"
);
"""

sql """
INSERT INTO test_null_predicate2 values
(1, null, "abc"),
(2, 2.0, "efg"),
(3, null, "ccc"),
(4, 4.0, "ddd"),
(5, null, "eeee");
"""

qt_select15 """ select * from test_null_predicate2 where `value` is null order by id; """
}