This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 03289c9c0f57a00b6fc609f35cf6ed6cc454bce9
Author: luozenglin <37725793+luozeng...@users.noreply.github.com>
AuthorDate: Fri Jan 13 11:37:07 2023 +0800

    [fix](bitmap) fix bitmap iterator comparison error (#15779)
    
    Fix the bug that bitmap.begin() == bitmap.end() is always true when the 
bitmap contains a single value.
---
 be/src/util/bitmap_value.h                                     |  2 +-
 be/test/util/bitmap_value_test.cpp                             | 10 +++++++---
 regression-test/data/query_p0/join/test_bitmap_filter.out      |  7 +++++++
 regression-test/suites/query_p0/join/test_bitmap_filter.groovy |  4 ++++
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/be/src/util/bitmap_value.h b/be/src/util/bitmap_value.h
index 2717f18895..21fa5f217e 100644
--- a/be/src/util/bitmap_value.h
+++ b/be/src/util/bitmap_value.h
@@ -1975,7 +1975,7 @@ public:
         case BitmapValue::BitmapDataType::EMPTY:
             return other._bitmap._type == BitmapValue::BitmapDataType::EMPTY;
         case BitmapValue::BitmapDataType::SINGLE:
-            return _sv == other._sv;
+            return _end == other._end && _sv == other._sv;
         case BitmapValue::BitmapDataType::BITMAP:
             return *_iter == *(other._iter);
         default:
diff --git a/be/test/util/bitmap_value_test.cpp 
b/be/test/util/bitmap_value_test.cpp
index 256fbbe914..ee950744db 100644
--- a/be/test/util/bitmap_value_test.cpp
+++ b/be/test/util/bitmap_value_test.cpp
@@ -390,9 +390,13 @@ TEST(BitmapValueTest, bitmap_value_iterator_test) {
     }
 
     BitmapValue single(1024);
-    for (auto iter = single.begin(); iter != single.end(); ++iter) {
-        EXPECT_EQ(1024, *iter);
-    }
+    auto single_iter = single.begin();
+    EXPECT_EQ(1024, *single_iter);
+    EXPECT_TRUE(single_iter == BitmapValue {1024}.begin());
+    EXPECT_TRUE(single_iter != single.end());
+
+    ++single_iter;
+    EXPECT_TRUE(single_iter == single.end());
 
     int i = 0;
     BitmapValue bitmap({0, 1025, 1026, UINT32_MAX, UINT64_MAX});
diff --git a/regression-test/data/query_p0/join/test_bitmap_filter.out 
b/regression-test/data/query_p0/join/test_bitmap_filter.out
index 9484c6770d..f44900b0e0 100644
--- a/regression-test/data/query_p0/join/test_bitmap_filter.out
+++ b/regression-test/data/query_p0/join/test_bitmap_filter.out
@@ -91,3 +91,10 @@
 1991
 32767
 
+-- !sql13 --
+10     1991
+
+-- !sql14 --
+1      1989
+10     1991
+
diff --git a/regression-test/suites/query_p0/join/test_bitmap_filter.groovy 
b/regression-test/suites/query_p0/join/test_bitmap_filter.groovy
index 78b33040b4..53522289c9 100644
--- a/regression-test/suites/query_p0/join/test_bitmap_filter.groovy
+++ b/regression-test/suites/query_p0/join/test_bitmap_filter.groovy
@@ -66,6 +66,10 @@ suite("test_bitmap_filter", "query_p0") {
         select * from (select * from w1 union select * from w2) tmp order by 1;
     """
 
+    qt_sql13 "select k1, k2 from ${tbl1} where k1 in (select to_bitmap(10)) 
order by 1, 2"
+
+    qt_sql14 "select k1, k2 from ${tbl1} where k1 in (select 
bitmap_from_string('1,10')) order by 1, 2"
+
     test {
         sql "select k1, k2 from ${tbl1} b1 where k1 in (select k2 from ${tbl2} 
b2 where b1.k2 = b2.k1) order by k1;"
         exception "In bitmap does not support correlated subquery"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to