This is an automated email from the ASF dual-hosted git repository.
jianliangqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new d9461d77ba [Fix](bitmap index) like predicate does not work in bitmap
index (#23819)
d9461d77ba is described below
commit d9461d77baad0026b8c80b4307044d0f35f83170
Author: airborne12 <[email protected]>
AuthorDate: Tue Sep 5 11:43:16 2023 +0800
[Fix](bitmap index) like predicate does not work in bitmap index (#23819)
---
be/src/olap/rowset/segment_v2/segment_iterator.cpp | 10 +++-
.../inverted_index_p0/test_index_like_select.out | 16 +++++++
.../test_index_like_select.groovy | 56 ++++++++++++++++++++++
3 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp
b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
index f445dab20d..aa2d228f2e 100644
--- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
@@ -523,10 +523,18 @@ Status SegmentIterator::_apply_bitmap_index() {
size_t input_rows = _row_bitmap.cardinality();
std::vector<ColumnPredicate*> remaining_predicates;
+ auto is_like_predicate = [](ColumnPredicate* _pred) {
+ if (static_cast<LikeColumnPredicate<TYPE_CHAR>*>(_pred) != nullptr ||
+ static_cast<LikeColumnPredicate<TYPE_STRING>*>(_pred) != nullptr) {
+ return true;
+ }
+ return false;
+ };
for (auto pred : _col_predicates) {
auto cid = pred->column_id();
- if (_bitmap_index_iterators[cid] == nullptr || pred->type() ==
PredicateType::BF) {
+ if (_bitmap_index_iterators[cid] == nullptr || pred->type() ==
PredicateType::BF ||
+ is_like_predicate(pred)) {
// no bitmap index for this column
remaining_predicates.push_back(pred);
} else {
diff --git a/regression-test/data/inverted_index_p0/test_index_like_select.out
b/regression-test/data/inverted_index_p0/test_index_like_select.out
index 1d96a1ec02..24701aec6e 100644
--- a/regression-test/data/inverted_index_p0/test_index_like_select.out
+++ b/regression-test/data/inverted_index_p0/test_index_like_select.out
@@ -157,6 +157,14 @@ zhang san grade 5 zhang yi chen san buy
dancing book 10 2017-10-01T00:00 tall:12
-- !sql --
22222222
+-- !sql --
+zhang san grade 5 zhang yi chen san 10
+zhang san yi grade 5 zhang yi chen san 11
+
+-- !sql --
+zhang san grade 5 zhang yi chen san 10
+zhang san yi grade 5 zhang yi chen san 11
+
-- !sql --
zhang san grade 5 zhang yi chen san buy dancing book
10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing,
dancing Like cultural and recreational activities Class activists
@@ -315,3 +323,11 @@ zhang san grade 5 zhang yi chen san buy
dancing book 10 2017-10-01T00:00 tall:12
-- !sql --
22222222
+-- !sql --
+zhang san grade 5 zhang yi chen san 10
+zhang san yi grade 5 zhang yi chen san 11
+
+-- !sql --
+zhang san grade 5 zhang yi chen san 10
+zhang san yi grade 5 zhang yi chen san 11
+
diff --git
a/regression-test/suites/inverted_index_p0/test_index_like_select.groovy
b/regression-test/suites/inverted_index_p0/test_index_like_select.groovy
index 7ae3087ce1..975fac2eaa 100644
--- a/regression-test/suites/inverted_index_p0/test_index_like_select.groovy
+++ b/regression-test/suites/inverted_index_p0/test_index_like_select.groovy
@@ -206,5 +206,61 @@ suite("test_index_like_select", "inverted_index_select"){
order by name
"""
qt_sql """select 22222222"""
+
+ // create DUP KEY table with bitmap index
+ def indexTbName2 = "bitmap_index_like"
+ sql "DROP TABLE IF EXISTS ${indexTbName2}"
+ sql """
+ CREATE TABLE IF NOT EXISTS ${indexTbName2} (
+ ${varchar_colume1} varchar(50),
+ ${varchar_colume2} varchar(30) NOT NULL,
+ ${varchar_colume3} varchar(50),
+ ${varchar_colume4} varchar(50),
+ ${int_colume1} int NOT NULL,
+ INDEX ${varchar_colume3}_idx(${varchar_colume3}) USING
BITMAP COMMENT ' ${varchar_colume3} index'
+ )
+ DUPLICATE KEY(`${varchar_colume1}`, `${varchar_colume2}`,
`${varchar_colume3}`, `${varchar_colume4}`)
+ DISTRIBUTED BY HASH(`${varchar_colume1}`) BUCKETS 10
+ properties("replication_num" = "1");
+ """
+ sql """ insert into ${indexTbName2} VALUES
+ ("zhang san", "grade 5", "zhang yi", "chen san", 10),
+ ("zhang san yi", "grade 5", "zhang yi", "chen san", 11),
+ ("li si", "grade 4", "li er", "wan jiu", 9),
+ ("san zhang", "grade 5", "", "", 10),
+ ("li sisi", "grade 6", "li ba", "li liuliu", 11)
+ """
+ sql """ set enable_function_pushdown=true; """
+ qt_sql """
+ select * from ${indexTbName2} where ${varchar_colume3} like
"zhang%" order by ${varchar_colume1}
+ """
+
+ // create AGG KEY table with bitmap index
+ def indexTbName3 = "bitmap_index_like2"
+ sql "DROP TABLE IF EXISTS ${indexTbName3}"
+ sql """
+ CREATE TABLE IF NOT EXISTS ${indexTbName3} (
+ ${varchar_colume1} varchar(50),
+ ${varchar_colume2} varchar(30) NOT NULL,
+ ${varchar_colume3} varchar(50),
+ ${varchar_colume4} varchar(50),
+ ${int_colume1} int SUM NULL DEFAULT "0",
+ INDEX ${varchar_colume3}_idx(${varchar_colume3}) USING
BITMAP COMMENT ' ${varchar_colume3} index'
+ )
+ AGGREGATE KEY(`${varchar_colume1}`, `${varchar_colume2}`,
`${varchar_colume3}`, `${varchar_colume4}`)
+ DISTRIBUTED BY HASH(`${varchar_colume1}`) BUCKETS 10
+ properties("replication_num" = "1");
+ """
+ sql """ insert into ${indexTbName3} VALUES
+ ("zhang san", "grade 5", "zhang yi", "chen san", 10),
+ ("zhang san yi", "grade 5", "zhang yi", "chen san", 11),
+ ("li si", "grade 4", "li er", "wan jiu", 9),
+ ("san zhang", "grade 5", "", "", 10),
+ ("li sisi", "grade 6", "li ba", "li liuliu", 11)
+ """
+ sql """ set enable_function_pushdown=true; """
+ qt_sql """
+ select * from ${indexTbName3} where ${varchar_colume3} like
"zhang%" order by ${varchar_colume1}
+ """
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]