This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new d9212d8545 [fix](agg) incorrect result of bitmap_agg and bitmap_union
(#23558)
d9212d8545 is described below
commit d9212d85455bacd5bbdbeb1b481c39db12fb5ded
Author: Jerry Hu <[email protected]>
AuthorDate: Mon Aug 28 14:22:19 2023 +0800
[fix](agg) incorrect result of bitmap_agg and bitmap_union (#23558)
---
.../aggregate_function_bitmap.h | 4 +-
.../aggregate_function_bitmap_agg.h | 4 +-
.../data/query_p0/aggregate/bitmap_agg.out | 10 +++++
.../suites/query_p0/aggregate/bitmap_agg.groovy | 50 ++++++++++++++++++++++
4 files changed, 64 insertions(+), 4 deletions(-)
diff --git a/be/src/vec/aggregate_functions/aggregate_function_bitmap.h
b/be/src/vec/aggregate_functions/aggregate_function_bitmap.h
index 7d2634a8dc..b070bae8c1 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_bitmap.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_bitmap.h
@@ -225,7 +225,7 @@ public:
auto& col = assert_cast<const ColumnBitmap&>(*assert_cast<const
IColumn*>(column));
auto* data = col.get_data().data();
for (size_t i = 0; i != num_rows; ++i) {
- this->data(places[i]).merge(data[i]);
+ this->data(places[i] + offset).merge(data[i]);
}
} else {
BaseHelper::deserialize_and_merge_vec(places, offset, rhs, column,
arena, num_rows);
@@ -240,7 +240,7 @@ public:
auto* data = col.get_data().data();
for (size_t i = 0; i != num_rows; ++i) {
if (places[i]) {
- this->data(places[i]).merge(data[i]);
+ this->data(places[i] + offset).merge(data[i]);
}
}
} else {
diff --git a/be/src/vec/aggregate_functions/aggregate_function_bitmap_agg.h
b/be/src/vec/aggregate_functions/aggregate_function_bitmap_agg.h
index d7b1fe72b9..382957302e 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_bitmap_agg.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_bitmap_agg.h
@@ -190,7 +190,7 @@ public:
auto& col = assert_cast<const ColumnBitmap&>(*assert_cast<const
IColumn*>(column));
auto* data = col.get_data().data();
for (size_t i = 0; i != num_rows; ++i) {
- this->data(places[i]).value |= data[i];
+ this->data(places[i] + offset).value |= data[i];
}
}
@@ -201,7 +201,7 @@ public:
auto* data = col.get_data().data();
for (size_t i = 0; i != num_rows; ++i) {
if (places[i]) {
- this->data(places[i]).value |= data[i];
+ this->data(places[i] + offset).value |= data[i];
}
}
}
diff --git a/regression-test/data/query_p0/aggregate/bitmap_agg.out
b/regression-test/data/query_p0/aggregate/bitmap_agg.out
index 82a80101eb..f078fe0f6e 100644
--- a/regression-test/data/query_p0/aggregate/bitmap_agg.out
+++ b/regression-test/data/query_p0/aggregate/bitmap_agg.out
@@ -5,3 +5,13 @@
-- !sql2 --
20000
+-- !sql3 --
+25 25 25
+
+-- !sql4 --
+5 5
+5 5
+5 5
+5 5
+5 5
+
diff --git a/regression-test/suites/query_p0/aggregate/bitmap_agg.groovy
b/regression-test/suites/query_p0/aggregate/bitmap_agg.groovy
index edfc246df0..7ee79c6186 100644
--- a/regression-test/suites/query_p0/aggregate/bitmap_agg.groovy
+++ b/regression-test/suites/query_p0/aggregate/bitmap_agg.groovy
@@ -69,4 +69,54 @@ suite("bitmap_agg") {
"""
sql "DROP TABLE IF EXISTS `test_bitmap_agg`;"
+ sql "DROP TABLE IF EXISTS `test_bitmap_agg_nation`;"
+ sql """
+ CREATE TABLE `test_bitmap_agg_nation` (
+ `N_NATIONKEY` int(11) NOT NULL,
+ `N_NAME` char(25) NOT NULL,
+ `N_REGIONKEY` int(11) NOT NULL,
+ `N_COMMENT` varchar(152) NULL
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`N_NATIONKEY`, `N_NAME`)
+ COMMENT 'OLAP'
+ DISTRIBUTED BY HASH(`N_NATIONKEY`) BUCKETS 3
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ );
+ """
+
+ sql """
+ INSERT INTO `test_bitmap_agg_nation` VALUES (0,'ALGERIA',0,' haggle.
carefully final deposits detect slyly agai'),
+ (1,'ARGENTINA',1,'al foxes promise slyly according to the regular
accounts. bold requests alon'),
+ (3,'CANADA',1,'eas hang ironic, silent packages. slyly regular
packages are furiously over the tithes. fluffily bold'),
+ (8,'INDIA',2,'ss excuses cajole slyly across the packages. deposits
print aroun'),
+ (13,'JORDAN',4,'ic deposits are blithely about the carefully regular
pa'),
+ (17,'PERU',1,'platelets. blithely pending dependencies use fluffily
across the even pinto beans. carefully silent accoun'),
+ (22,'RUSSIA',3,' requests against the platelets use never according to
the quickly regular pint'),
+ (2,'BRAZIL',1,'y alongside of the pending deposits. carefully special
packages are about the ironic forges. slyly special '),
+ (9,'INDONESIA',2,' slyly express asymptotes. regular deposits haggle
slyly. carefully ironic hockey players sleep blithely. carefull'),
+ (10,'IRAN',4,'efully alongside of the slyly final dependencies. '),
+ (11,'IRAQ',4,'nic deposits boost atop the quickly final requests?
quickly regula'),
+ (12,'JAPAN',2,'ously. final, express gifts cajole a'),
+ (15,'MOROCCO',0,'rns. blithely bold courts among the closely regular
packages use furiously bold platelets?'),
+ (18,'CHINA',2,'c dependencies. furiously express notornis sleep slyly
regular accounts. ideas sleep. depos'),
+ (21,'VIETNAM',2,'hely enticingly express accounts. even, final '),
+ (24,'UNITED STATES',1,'y final packages. slow foxes cajole quickly.
quickly silent platelets breach ironic accounts. unusual pinto be'),
+ (14,'KENYA',0,' pending excuses haggle furiously deposits. pending,
express pinto beans wake fluffily past t'),
+ (16,'MOZAMBIQUE',0,'s. ironic, unusual asymptotes wake blithely r'),
+ (19,'ROMANIA',3,'ular asymptotes are about the furious multipliers.
express dependencies nag above the ironically ironic account'),
+ (20,'SAUDI ARABIA',4,'ts. silent requests haggle. closely express
packages sleep across the blithely'),
+ (23,'UNITED KINGDOM',3,'eans boost carefully special requests.
accounts are. carefull'),
+ (4,'EGYPT',4,'y above the carefully unusual theodolites. final dugouts
are quickly across the furiously regular d'),
+ (5,'ETHIOPIA',0,'ven packages wake quickly.
regu'),(6,'FRANCE',3,'refully final requests. regular, ironi'),
+ (7,'GERMANY',3,'l platelets. regular accounts x-ray: unusual, regular
acco');
+ """
+
+ qt_sql3 """
+ select count(`n_nationkey`), count(distinct `n_nationkey`),
bitmap_count(bitmap_agg(`n_nationkey`)) from `test_bitmap_agg_nation`;
+ """
+ qt_sql4 """
+ select count(`n_nationkey`), bitmap_count(bitmap_agg(`n_nationkey`))
from `test_bitmap_agg_nation` group by `n_regionkey`;
+ """
+ sql "DROP TABLE IF EXISTS `test_bitmap_agg_nation`;"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]