Skip to content

Commit

Permalink
fix index match null
Browse files Browse the repository at this point in the history
  • Loading branch information
airborne12 committed Oct 12, 2024
1 parent ea20867 commit 6f5432b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
4 changes: 4 additions & 0 deletions be/src/vec/functions/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Status FunctionMatchBase::evaluate_inverted_index(
std::shared_ptr<roaring::Roaring> roaring = std::make_shared<roaring::Roaring>();
Field param_value;
arguments[0].column->get(0, param_value);
if (param_value.is_null()) {
// if query value is null, skip evaluate inverted index
return Status::OK();
}
auto param_type = arguments[0].type->get_type_as_type_descriptor().type;
if (!is_string_type(param_type)) {
return Status::Error<ErrorCode::INVERTED_INDEX_INVALID_PARAMETERS>(
Expand Down
4 changes: 4 additions & 0 deletions regression-test/data/inverted_index_p0/test_null_index.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@

-- !sql --

-- !sql --

-- !sql --

30 changes: 28 additions & 2 deletions regression-test/suites/inverted_index_p0/test_null_index.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ suite("test_null_index", "p0"){
`id` int(11) NOT NULL,
`str` string NOT NULL,
`str_null` string NULL,
`value` array<text> NOT NULL,
`value_int` array<int> NOT NULL
`value` array<text> NOT NULL,
`value_int` array<int> NOT NULL
) ENGINE=OLAP
DUPLICATE KEY(`id`)
COMMENT 'OLAP'
Expand All @@ -48,4 +48,30 @@ suite("test_null_index", "p0"){
sql "INSERT INTO $indexTblName VALUES (1, 'a', null, [null], [1]), (2, 'b', 'b', ['b'], [2]), (3, 'c', 'c', ['c'], [3]);"
qt_sql "SELECT * FROM $indexTblName WHERE str match null order by id;"
qt_sql "SELECT * FROM $indexTblName WHERE str_null match null order by id;"

def indexTblName2 = "with_index_test"

sql "DROP TABLE IF EXISTS ${indexTblName2}"
// create 1 replica table
sql """
CREATE TABLE IF NOT EXISTS ${indexTblName2}(
`id` int(11) NOT NULL,
`str` string NOT NULL,
`str_null` string NULL,
`value` array<text> NOT NULL,
`value_int` array<int> NOT NULL,
INDEX str_idx(`str`) USING INVERTED,
INDEX str_null_idx(`str_null`) USING INVERTED
) ENGINE=OLAP
DUPLICATE KEY(`id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES(
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """ set enable_common_expr_pushdown = true """
sql "INSERT INTO $indexTblName2 VALUES (1, 'a', null, [null], [1]), (2, 'b', 'b', ['b'], [2]), (3, 'c', 'c', ['c'], [3]);"
qt_sql "SELECT * FROM $indexTblName2 WHERE str match null order by id;"
qt_sql "SELECT * FROM $indexTblName2 WHERE str_null match null order by id;"
}

0 comments on commit 6f5432b

Please sign in to comment.