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/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 3b04d42779 [fix](bitmap) fix bug: orthogonal_bitmap_union_count
coredump when arg is nullable (#18182)
3b04d42779 is described below
commit 3b04d42779214fc17f27990081584a9dac8388ad
Author: TengJianPing <[email protected]>
AuthorDate: Thu Mar 30 09:31:58 2023 +0800
[fix](bitmap) fix bug: orthogonal_bitmap_union_count coredump when arg is
nullable (#18182)
Query cause be cordump:
select ORTHOGONAL_BITMAP_UNION_COUNT( cast(null as bitmap)) from t;
---
.../aggregate_function_orthogonal_bitmap.cpp | 3 ++-
.../aggregate_function_orthogonal_bitmap.h | 3 ++-
.../bitmap_functions/test_bitmap_function.out | 18 ++++++++++++++++++
.../bitmap_functions/test_bitmap_function.out | 18 ++++++++++++++++++
.../bitmap_functions/test_bitmap_function.groovy | 22 +++++++++++++++++++++-
.../bitmap_functions/test_bitmap_function.groovy | 21 ++++++++++++++++++++-
6 files changed, 81 insertions(+), 4 deletions(-)
diff --git
a/be/src/vec/aggregate_functions/aggregate_function_orthogonal_bitmap.cpp
b/be/src/vec/aggregate_functions/aggregate_function_orthogonal_bitmap.cpp
index 40876e2b87..3f182a88c3 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_orthogonal_bitmap.cpp
+++ b/be/src/vec/aggregate_functions/aggregate_function_orthogonal_bitmap.cpp
@@ -32,7 +32,8 @@ AggregateFunctionPtr
create_aggregate_function_orthogonal(const std::string& nam
LOG(WARNING) << "Incorrect number of arguments for aggregate function
" << name;
return nullptr;
} else if (argument_types.size() == 1) {
- return
std::make_shared<AggFunctionOrthBitmapFunc<Impl<StringRef>>>(argument_types);
+ return
creator_without_type::create<AggFunctionOrthBitmapFunc<Impl<StringRef>>>(
+ argument_types, result_is_nullable);
} else {
WhichDataType which(*remove_nullable(argument_types[1]));
diff --git
a/be/src/vec/aggregate_functions/aggregate_function_orthogonal_bitmap.h
b/be/src/vec/aggregate_functions/aggregate_function_orthogonal_bitmap.h
index 20b90cd30e..16f16eaf98 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_orthogonal_bitmap.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_orthogonal_bitmap.h
@@ -171,7 +171,8 @@ public:
void get(IColumn& to) const {
auto& column = static_cast<ColumnVector<Int64>&>(to);
- column.get_data().emplace_back(result);
+ column.get_data().emplace_back(result ? result
+ :
AggOrthBitmapBaseData<T>::bitmap.intersect_count());
}
private:
diff --git
a/regression-test/data/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.out
b/regression-test/data/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.out
index 57a71aceb9..d344ad27bf 100644
---
a/regression-test/data/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.out
+++
b/regression-test/data/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.out
@@ -430,6 +430,24 @@ true
-- !sql --
0
+-- !sql_orthogonal_bitmap_intersect_count2 --
+0
+
+-- !sql_orthogonal_bitmap_intersect_count3_1 --
+2
+
+-- !sql_orthogonal_bitmap_intersect_count3_2 --
+2
+
+-- !sql_orthogonal_bitmap_intersect_count4 --
+1
+
+-- !sql_orthogonal_bitmap_union_count2 --
+0
+
+-- !sql_orthogonal_bitmap_union_count3 --
+4
+
-- !sql --
1,2,3
diff --git
a/regression-test/data/query_p0/sql_functions/bitmap_functions/test_bitmap_function.out
b/regression-test/data/query_p0/sql_functions/bitmap_functions/test_bitmap_function.out
index 8cb5e56a7f..53f5f731db 100644
---
a/regression-test/data/query_p0/sql_functions/bitmap_functions/test_bitmap_function.out
+++
b/regression-test/data/query_p0/sql_functions/bitmap_functions/test_bitmap_function.out
@@ -430,6 +430,24 @@ true
-- !sql --
0
+-- !sql_orthogonal_bitmap_intersect_count2 --
+0
+
+-- !sql_orthogonal_bitmap_intersect_count3_1 --
+2
+
+-- !sql_orthogonal_bitmap_intersect_count3_2 --
+2
+
+-- !sql_orthogonal_bitmap_intersect_count4 --
+1
+
+-- !sql_orthogonal_bitmap_union_count2 --
+0
+
+-- !sql_orthogonal_bitmap_union_count3 --
+4
+
-- !sql --
[1, 2, 3]
[1, 2, 3, 4, 5]
diff --git
a/regression-test/suites/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
b/regression-test/suites/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
index 53f08d6ce5..a08dc1f21c 100644
---
a/regression-test/suites/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
+++
b/regression-test/suites/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
@@ -598,11 +598,31 @@ suite("test_bitmap_function") {
// ARTHOGONAL_BITMAP_****
def arthogonalBitmapTable = "test_arthogonal_bitmap"
sql """ DROP TABLE IF EXISTS ${arthogonalBitmapTable} """
- sql """ CREATE TABLE IF NOT EXISTS ${arthogonalBitmapTable} ( tag_group
bigint(20) NULL COMMENT "标签组", tag_value_id varchar(64) NULL COMMENT "标签值",
tag_range int(11) NOT NULL DEFAULT "0" COMMENT "", partition_sign varchar(32)
NOT NULL COMMENT "分区标识", bucket int(11) NOT NULL COMMENT "分桶字段", confidence
tinyint(4) NULL DEFAULT "100" COMMENT "置信度", members bitmap BITMAP_UNION NULL
COMMENT "人群") ENGINE=OLAP AGGREGATE KEY(tag_group, tag_value_id, tag_range,
partition_sign, bucket, confiden [...]
+ sql """ CREATE TABLE IF NOT EXISTS ${arthogonalBitmapTable} (
+ tag_group bigint(20) NULL COMMENT "标签组",
+ bucket int(11) NOT NULL COMMENT "分桶字段",
+ members bitmap BITMAP_UNION NULL COMMENT "人群") ENGINE=OLAP
+ AGGREGATE KEY(tag_group,
+ bucket)
+ DISTRIBUTED BY HASH(bucket) BUCKETS 64
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "disable_auto_compaction" = "true",
+ "storage_format" = "V2");
+ """
+
+ sql """ insert into ${arthogonalBitmapTable} values (1, 1,
bitmap_from_string("1,11,111")), (2, 2, to_bitmap(2)); """
+ sql """ insert into ${arthogonalBitmapTable} values (11, 1,
bitmap_from_string("1,11")), (12, 2, to_bitmap(2)); """
qt_sql """ select orthogonal_bitmap_intersect(members, tag_group, 1150000,
1150001, 390006) from ${arthogonalBitmapTable} where tag_group in ( 1150000,
1150001, 390006); """
qt_sql """ select orthogonal_bitmap_intersect_count(members, tag_group,
1150000, 1150001, 390006) from ${arthogonalBitmapTable} where tag_group in (
1150000, 1150001, 390006); """
qt_sql """ select orthogonal_bitmap_union_count(members) from
${arthogonalBitmapTable} where tag_group in ( 1150000, 1150001, 390006); """
+ qt_sql_orthogonal_bitmap_intersect_count2 """ select
orthogonal_bitmap_intersect_count(members, tag_group, 1,2) from
test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_intersect_count3_1 """ select
/*+SET_VAR(parallel_fragment_exec_instance_num=1)*/orthogonal_bitmap_intersect_count(members,
tag_group, 1,11) from test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_intersect_count3_2 """ select
/*+SET_VAR(parallel_fragment_exec_instance_num=2)*/orthogonal_bitmap_intersect_count(members,
tag_group, 1,11) from test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_intersect_count4 """ select
orthogonal_bitmap_intersect_count(members, tag_group, 2,12) from
test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_union_count2 """ select
orthogonal_bitmap_union_count( cast(null as bitmap)) from
test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_union_count3 """ select
orthogonal_bitmap_union_count(members) from test_arthogonal_bitmap; """
// Nereids does't support array function
// qt_sql """ select bitmap_to_array(user_id) from ${intersectCountTable}
order by dt desc; """
diff --git
a/regression-test/suites/query_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
b/regression-test/suites/query_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
index f025ef1643..b4cf3cdc3b 100644
---
a/regression-test/suites/query_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
+++
b/regression-test/suites/query_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
@@ -596,11 +596,30 @@ suite("test_bitmap_function") {
// ARTHOGONAL_BITMAP_****
def arthogonalBitmapTable = "test_arthogonal_bitmap"
sql """ DROP TABLE IF EXISTS ${arthogonalBitmapTable} """
- sql """ CREATE TABLE IF NOT EXISTS ${arthogonalBitmapTable} ( tag_group
bigint(20) NULL COMMENT "标签组", tag_value_id varchar(64) NULL COMMENT "标签值",
tag_range int(11) NOT NULL DEFAULT "0" COMMENT "", partition_sign varchar(32)
NOT NULL COMMENT "分区标识", bucket int(11) NOT NULL COMMENT "分桶字段", confidence
tinyint(4) NULL DEFAULT "100" COMMENT "置信度", members bitmap BITMAP_UNION NULL
COMMENT "人群") ENGINE=OLAP AGGREGATE KEY(tag_group, tag_value_id, tag_range,
partition_sign, bucket, confiden [...]
+ sql """ CREATE TABLE IF NOT EXISTS ${arthogonalBitmapTable} (
+ tag_group bigint(20) NULL COMMENT "标签组",
+ bucket int(11) NOT NULL COMMENT "分桶字段",
+ members bitmap BITMAP_UNION NULL COMMENT "人群") ENGINE=OLAP
+ AGGREGATE KEY(tag_group,
+ bucket)
+ DISTRIBUTED BY HASH(bucket) BUCKETS 64
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "storage_format" = "V2");
+ """
+
+ sql """ insert into ${arthogonalBitmapTable} values (1, 1,
bitmap_from_string("1,11,111")), (2, 2, to_bitmap(2)); """
+ sql """ insert into ${arthogonalBitmapTable} values (11, 1,
bitmap_from_string("1,11")), (12, 2, to_bitmap(2)); """
qt_sql """ select orthogonal_bitmap_intersect(members, tag_group, 1150000,
1150001, 390006) from ${arthogonalBitmapTable} where tag_group in ( 1150000,
1150001, 390006); """
qt_sql """ select orthogonal_bitmap_intersect_count(members, tag_group,
1150000, 1150001, 390006) from ${arthogonalBitmapTable} where tag_group in (
1150000, 1150001, 390006); """
qt_sql """ select orthogonal_bitmap_union_count(members) from
${arthogonalBitmapTable} where tag_group in ( 1150000, 1150001, 390006); """
+ qt_sql_orthogonal_bitmap_intersect_count2 """ select
orthogonal_bitmap_intersect_count(members, tag_group, 1,2) from
test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_intersect_count3_1 """ select
/*+SET_VAR(parallel_fragment_exec_instance_num=1)*/orthogonal_bitmap_intersect_count(members,
tag_group, 1,11) from test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_intersect_count3_2 """ select
/*+SET_VAR(parallel_fragment_exec_instance_num=2)*/orthogonal_bitmap_intersect_count(members,
tag_group, 1,11) from test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_intersect_count4 """ select
orthogonal_bitmap_intersect_count(members, tag_group, 2,12) from
test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_union_count2 """ select
orthogonal_bitmap_union_count( cast(null as bitmap)) from
test_arthogonal_bitmap; """
+ qt_sql_orthogonal_bitmap_union_count3 """ select
orthogonal_bitmap_union_count(members) from test_arthogonal_bitmap; """
qt_sql """ select bitmap_to_array(user_id) from ${intersectCountTable}
order by dt desc; """
qt_sql """ select bitmap_to_array(bitmap_empty()); """
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]