You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/06/09 00:45:55 UTC

[incubator-doris] branch master updated: [Bugfix] be crash when executing sql contains bitmap_intersect function (#9910)

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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new bf8b4fb2d3 [Bugfix] be crash when executing sql contains bitmap_intersect function (#9910)
bf8b4fb2d3 is described below

commit bf8b4fb2d3415b8f129f03a563884cea841e496d
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Thu Jun 9 08:45:46 2022 +0800

    [Bugfix] be crash when executing sql contains bitmap_intersect function (#9910)
    
    * fix bitmap serialize bug
    
    * add regression test for bitmap seralize bugfix
    
    * add missing regression test out file
    
    * fix reggresion test failed issue
---
 be/src/exprs/bitmap_function.cpp                   |  3 +-
 .../data/correctness/test_bitmap_serialize.out     |  4 +++
 .../correctness/test_bitmap_serialize.groovy       | 39 ++++++++++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/be/src/exprs/bitmap_function.cpp b/be/src/exprs/bitmap_function.cpp
index d49863ab73..5e38ab8f79 100644
--- a/be/src/exprs/bitmap_function.cpp
+++ b/be/src/exprs/bitmap_function.cpp
@@ -393,7 +393,8 @@ StringVal BitmapFunctions::bitmap_hash(doris_udf::FunctionContext* ctx,
 
 StringVal BitmapFunctions::bitmap_serialize(FunctionContext* ctx, const StringVal& src) {
     if (src.is_null) {
-        return src;
+        // bitmap functions should never return nullable value
+        return serialize(ctx, nullptr);
     }
 
     auto src_bitmap = reinterpret_cast<BitmapValue*>(src.ptr);
diff --git a/regression-test/data/correctness/test_bitmap_serialize.out b/regression-test/data/correctness/test_bitmap_serialize.out
new file mode 100644
index 0000000000..a36fb412ce
--- /dev/null
+++ b/regression-test/data/correctness/test_bitmap_serialize.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !select_default --
+
+
diff --git a/regression-test/suites/correctness/test_bitmap_serialize.groovy b/regression-test/suites/correctness/test_bitmap_serialize.groovy
new file mode 100644
index 0000000000..b988316213
--- /dev/null
+++ b/regression-test/suites/correctness/test_bitmap_serialize.groovy
@@ -0,0 +1,39 @@
+// 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("test_bitmap_serialize") {
+     def tableName = "test_bitmap"
+
+     sql """ DROP TABLE IF EXISTS ${tableName} """
+     sql """
+        create table ${tableName} (tag varchar(20),user_ids bitmap bitmap_union) aggregate key (tag) 
+        distributed by hash (tag) PROPERTIES("replication_num" = "1"); 
+     """
+
+     sql " insert into ${tableName} values('A', to_bitmap(1)); "
+     sql " insert into ${tableName} values('A', to_bitmap(2)); "
+     sql " insert into ${tableName} values('A', to_bitmap(3)); "
+     sql " insert into ${tableName} values('B', to_bitmap(1)); "
+     sql " insert into ${tableName} values('B', to_bitmap(2)); "
+
+     // test no vectorized
+     sql """ set enable_vectorized_engine = false; """
+
+     qt_select_default """ 
+     select bitmap_to_string(bitmap_intersect(user_ids)) from ( select tag, bitmap_union(user_ids) user_ids 
+     from ${tableName} group by tag having tag not in("A","B") ) t; """
+ } 
\ No newline at end of file


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