You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/12/26 04:24:21 UTC
(doris) branch branch-2.0 updated: [fix](nereids)add HllUnion and BitmapUnion for pre agg match #27548 (#28971)
This is an automated email from the ASF dual-hosted git repository.
kxiao 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 9cad9cb23f0 [fix](nereids)add HllUnion and BitmapUnion for pre agg match #27548 (#28971)
9cad9cb23f0 is described below
commit 9cad9cb23f0c9beac8dc48142c3f72c7879229c3
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Tue Dec 26 12:24:15 2023 +0800
[fix](nereids)add HllUnion and BitmapUnion for pre agg match #27548 (#28971)
---
.../mv/SelectMaterializedIndexWithAggregate.java | 25 ++++++++++++++++++++++
.../org/apache/doris/planner/QueryPlanTest.java | 6 +++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
index 65e1e0c4b80..825a9f9ac17 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/SelectMaterializedIndexWithAggregate.java
@@ -42,6 +42,7 @@ import org.apache.doris.nereids.trees.expressions.SlotNotFromChildren;
import org.apache.doris.nereids.trees.expressions.SlotReference;
import org.apache.doris.nereids.trees.expressions.VirtualSlotReference;
import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction;
+import org.apache.doris.nereids.trees.expressions.functions.agg.BitmapUnion;
import org.apache.doris.nereids.trees.expressions.functions.agg.BitmapUnionCount;
import org.apache.doris.nereids.trees.expressions.functions.agg.Count;
import org.apache.doris.nereids.trees.expressions.functions.agg.HllUnion;
@@ -884,6 +885,20 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
}
}
+ @Override
+ public PreAggStatus visitBitmapUnion(BitmapUnion bitmapUnion, CheckContext context) {
+ Expression expr = bitmapUnion.child();
+ if (expr instanceof ToBitmap) {
+ expr = expr.child(0);
+ }
+ Optional<Slot> slotOpt = ExpressionUtils.extractSlotOrCastOnSlot(expr);
+ if (slotOpt.isPresent() && context.valueNameToColumn.containsKey(normalizeName(slotOpt.get().toSql()))) {
+ return PreAggStatus.on();
+ } else {
+ return PreAggStatus.off("invalid bitmap_union: " + bitmapUnion.toSql());
+ }
+ }
+
@Override
public PreAggStatus visitHllUnionAgg(HllUnionAgg hllUnionAgg, CheckContext context) {
Optional<Slot> slotOpt = ExpressionUtils.extractSlotOrCastOnSlot(hllUnionAgg.child());
@@ -894,6 +909,16 @@ public class SelectMaterializedIndexWithAggregate extends AbstractSelectMaterial
}
}
+ @Override
+ public PreAggStatus visitHllUnion(HllUnion hllUnion, CheckContext context) {
+ Optional<Slot> slotOpt = ExpressionUtils.extractSlotOrCastOnSlot(hllUnion.child());
+ if (slotOpt.isPresent() && context.valueNameToColumn.containsKey(normalizeName(slotOpt.get().toSql()))) {
+ return PreAggStatus.on();
+ } else {
+ return PreAggStatus.off("invalid hll_union: " + hllUnion.toSql());
+ }
+ }
+
private PreAggStatus checkAggFunc(
AggregateFunction aggFunc,
AggregateType matchingAggType,
diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
index 02caf943c49..bcf239b443c 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
@@ -2185,11 +2185,11 @@ public class QueryPlanTest extends TestWithFeService {
+ " \"replication_num\" = \"1\"\n"
+ ");");
- String queryBaseTableStr = "explain select /*+ SET_VAR(enable_nereids_planner=false) */ id,id2,orthogonal_bitmap_union_count(id3) from test.bitmap_tb t1 group by id,id2";
+ String queryBaseTableStr = "explain select id,id2,orthogonal_bitmap_union_count(id3) from test.bitmap_tb t1 group by id,id2";
String explainString1 = getSQLPlanOrErrorMsg(queryBaseTableStr);
Assert.assertTrue(explainString1.contains("PREAGGREGATION: ON"));
- String queryTableStr = "explain select /*+ SET_VAR(enable_nereids_planner=false) */ id,orthogonal_bitmap_union_count(id3) from test.bitmap_tb t1 group by id";
+ String queryTableStr = "explain select id,orthogonal_bitmap_union_count(id3) from test.bitmap_tb t1 group by id";
String explainString2 = getSQLPlanOrErrorMsg(queryTableStr);
Assert.assertTrue(explainString2.contains("PREAGGREGATION: ON"));
}
@@ -2212,7 +2212,7 @@ public class QueryPlanTest extends TestWithFeService {
+ " \"in_memory\"=\"false\"\n"
+ ");");
- String queryBaseTableStr = "explain select /*+ SET_VAR(enable_nereids_planner=false) */ dt, hll_union(pv) from test.test_hll group by dt";
+ String queryBaseTableStr = "explain select dt, hll_union(pv) from test.test_hll group by dt";
String explainString = getSQLPlanOrErrorMsg(queryBaseTableStr);
Assert.assertTrue(explainString.contains("PREAGGREGATION: ON"));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org