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 62d06584f1e [feature](fe) add function 'BitmapAgg' in nereids (#25508)
62d06584f1e is described below
commit 62d06584f1e9d12c0d5a0e2b6ad0991b216e8b93
Author: Jerry Hu <[email protected]>
AuthorDate: Wed Oct 18 14:24:27 2023 +0800
[feature](fe) add function 'BitmapAgg' in nereids (#25508)
---
.../doris/catalog/BuiltinAggregateFunctions.java | 2 +
.../trees/expressions/functions/agg/BitmapAgg.java | 66 ++++++++++++++++++++++
.../visitor/AggregateFunctionVisitor.java | 5 ++
.../data/nereids_function_p0/agg_function/agg.out | 20 +++++++
.../nereids_function_p0/agg_function/agg.groovy | 14 +++++
5 files changed, 107 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
index f4e62d4f772..51bccc47e42 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
@@ -20,6 +20,7 @@ package org.apache.doris.catalog;
import org.apache.doris.nereids.trees.expressions.functions.agg.AnyValue;
import org.apache.doris.nereids.trees.expressions.functions.agg.Avg;
import org.apache.doris.nereids.trees.expressions.functions.agg.AvgWeighted;
+import org.apache.doris.nereids.trees.expressions.functions.agg.BitmapAgg;
import
org.apache.doris.nereids.trees.expressions.functions.agg.BitmapIntersect;
import org.apache.doris.nereids.trees.expressions.functions.agg.BitmapUnion;
import
org.apache.doris.nereids.trees.expressions.functions.agg.BitmapUnionCount;
@@ -82,6 +83,7 @@ public class BuiltinAggregateFunctions implements
FunctionHelper {
agg(AnyValue.class, "any", "any_value"),
agg(Avg.class, "avg"),
agg(AvgWeighted.class, "avg_weighted"),
+ agg(BitmapAgg.class, "bitmap_agg"),
agg(BitmapIntersect.class, "bitmap_intersect"),
agg(BitmapUnion.class, "bitmap_union"),
agg(BitmapUnionCount.class, "bitmap_union_count"),
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/BitmapAgg.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/BitmapAgg.java
new file mode 100644
index 00000000000..5b348b07318
--- /dev/null
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/BitmapAgg.java
@@ -0,0 +1,66 @@
+// 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.
+
+package org.apache.doris.nereids.trees.expressions.functions.agg;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable;
+import
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
+import org.apache.doris.nereids.types.BigIntType;
+import org.apache.doris.nereids.types.BitmapType;
+import org.apache.doris.nereids.types.IntegerType;
+import org.apache.doris.nereids.types.SmallIntType;
+import org.apache.doris.nereids.types.TinyIntType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * AggregateFunction 'bitmap_agg'.
+ */
+public class BitmapAgg extends AggregateFunction
+ implements UnaryExpression, ExplicitlyCastableSignature,
AlwaysNotNullable {
+ public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+
FunctionSignature.ret(BitmapType.INSTANCE).args(TinyIntType.INSTANCE),
+
FunctionSignature.ret(BitmapType.INSTANCE).args(SmallIntType.INSTANCE),
+
FunctionSignature.ret(BitmapType.INSTANCE).args(IntegerType.INSTANCE),
+
FunctionSignature.ret(BitmapType.INSTANCE).args(BigIntType.INSTANCE)
+ );
+
+ public BitmapAgg(Expression arg0) {
+ super("bitmap_agg", arg0);
+ }
+
+ public BitmapAgg(boolean distinct, Expression arg0) {
+ super("bitmap_agg", distinct, arg0);
+ }
+
+ @Override
+ public List<FunctionSignature> getSignatures() {
+ return SIGNATURES;
+ }
+
+ @Override
+ public AggregateFunction withDistinctAndChildren(boolean distinct,
List<Expression> children) {
+ Preconditions.checkArgument(children.size() == 1);
+ return new BitmapAgg(distinct, children.get(0));
+ }
+}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
index 280b8c47ab6..012906bdf52 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
@@ -21,6 +21,7 @@ import
org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunctio
import org.apache.doris.nereids.trees.expressions.functions.agg.AnyValue;
import org.apache.doris.nereids.trees.expressions.functions.agg.Avg;
import org.apache.doris.nereids.trees.expressions.functions.agg.AvgWeighted;
+import org.apache.doris.nereids.trees.expressions.functions.agg.BitmapAgg;
import
org.apache.doris.nereids.trees.expressions.functions.agg.BitmapIntersect;
import org.apache.doris.nereids.trees.expressions.functions.agg.BitmapUnion;
import
org.apache.doris.nereids.trees.expressions.functions.agg.BitmapUnionCount;
@@ -91,6 +92,10 @@ public interface AggregateFunctionVisitor<R, C> {
return visitAggregateFunction(avgWeighted, context);
}
+ default R visitBitmapAgg(BitmapAgg bitmapAgg, C context) {
+ return visitAggregateFunction(bitmapAgg, context);
+ }
+
default R visitBitmapIntersect(BitmapIntersect bitmapIntersect, C context)
{
return visitAggregateFunction(bitmapIntersect, context);
}
diff --git a/regression-test/data/nereids_function_p0/agg_function/agg.out
b/regression-test/data/nereids_function_p0/agg_function/agg.out
index 8474651326b..78573751cb0 100644
--- a/regression-test/data/nereids_function_p0/agg_function/agg.out
+++ b/regression-test/data/nereids_function_p0/agg_function/agg.out
@@ -923,6 +923,26 @@
-- !sql_bitmap_intersect_Bitmap_agg_phase_4_notnull --
12 \N
+-- !sql_bitmap_agg_tinyint --
+0
+7
+5
+
+-- !sql_bitmap_agg_smallint --
+0
+7
+5
+
+-- !sql_bitmap_agg_int --
+0
+7
+5
+
+-- !sql_bitmap_agg_bigint --
+0
+7
+5
+
-- !sql_bitmap_union_Bitmap_gb --
\N
\N
diff --git a/regression-test/suites/nereids_function_p0/agg_function/agg.groovy
b/regression-test/suites/nereids_function_p0/agg_function/agg.groovy
index c153cb903af..870b66d3392 100644
--- a/regression-test/suites/nereids_function_p0/agg_function/agg.groovy
+++ b/regression-test/suites/nereids_function_p0/agg_function/agg.groovy
@@ -399,6 +399,20 @@ suite("nereids_agg_fn") {
qt_sql_bitmap_intersect_Bitmap_agg_phase_4_notnull '''
select
/*+SET_VAR(disable_nereids_rules='THREE_PHASE_AGGREGATE_WITH_DISTINCT,
TWO_PHASE_AGGREGATE_WITH_DISTINCT')*/ count(distinct id),
bitmap_intersect(bitmap_hash(kbint)) from fn_test'''
+ // bitmap_agg
+ qt_sql_bitmap_agg_tinyint """
+ select bitmap_count(b) from (select kbool, bitmap_agg(ktint) b from
fn_test group by kbool) a order by kbool
+ """
+ qt_sql_bitmap_agg_smallint """
+ select bitmap_count(b) from (select kbool, bitmap_agg(ksint) b from
fn_test group by kbool) a order by kbool
+ """
+ qt_sql_bitmap_agg_int """
+ select bitmap_count(b) from (select kbool, bitmap_agg(kint) b from
fn_test group by kbool) a order by kbool
+ """
+ qt_sql_bitmap_agg_bigint """
+ select bitmap_count(b) from (select kbool, bitmap_agg(kbint) b from
fn_test group by kbool) a order by kbool
+ """
+
qt_sql_bitmap_union_Bitmap_gb '''
select bitmap_union(bitmap_hash(kbint)) from fn_test group by
kbool order by kbool'''
qt_sql_bitmap_union_Bitmap '''
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]