morrySnow commented on code in PR #12785:
URL: https://github.com/apache/doris/pull/12785#discussion_r978252987
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/mv/SelectRollupWithAggregate.java:
##########
@@ -172,23 +183,33 @@ public List<Rule> buildRules() {
/**
* Select candidate rollup ids.
* <p>
- * todo: 0. turn off pre agg, checking input aggregate functions and group
by expressions, etc.
+ * 0. turn off pre agg, checking input aggregate functions and group by
expressions, etc.
* 1. rollup contains all the required output slots.
* 2. match the most prefix index if pushdown predicates present.
+ * 3. sort the result matching rollup index ids.
*/
- private List<Long> selectCandidateRollupIds(
- LogicalOlapScan olapScan,
+ private Pair<PreAggStatus, List<Long>> selectCandidateRollupIds(
+ LogicalOlapScan scan,
Set<Slot> requiredScanOutput,
List<Expression> predicates,
// not used now, reserved for checking aggregate function type
match.
- List<AggregateFunction> aggregateFunctions) {
-
Preconditions.checkArgument(Sets.newHashSet(olapScan.getOutput()).containsAll(requiredScanOutput),
- "Scan's output should contains all the input required scan
output.");
+ List<AggregateFunction> aggregateFunctions,
+ List<Expression> groupingExprs) {
+
Preconditions.checkArgument(Sets.newHashSet(scan.getOutput()).containsAll(requiredScanOutput),
Review Comment:
we have a new interface to get output set, however, it returns a set of
exprid. I don't know if you can use it directly here
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PreAggStatus.java:
##########
@@ -0,0 +1,75 @@
+// 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.plans;
+
+import java.util.function.Supplier;
+
+/**
+ * Pre-aggregate status for OLAP scan table.
+ */
+public class PreAggStatus {
+ private enum Status {
+ ON, OFF
+ }
+
+ private static PreAggStatus PRE_AGG_ON = new PreAggStatus(Status.ON, "");
Review Comment:
final
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/batch/NereidsRewriteJobExecutor.java:
##########
@@ -70,7 +71,8 @@ public NereidsRewriteJobExecutor(CascadesContext
cascadesContext) {
.add(topDownBatch(ImmutableList.of(new EliminateLimit())))
.add(topDownBatch(ImmutableList.of(new EliminateFilter())))
.add(topDownBatch(ImmutableList.of(new
PruneOlapScanPartition())))
- .add(topDownBatch(ImmutableList.of(new SelectRollup())))
+ .add(topDownBatch(ImmutableList.of(new
SelectRollupWithAggregate())))
+ .add(topDownBatch(ImmutableList.of(new
SelectRollupWithoutAggregate())))
Review Comment:
should we apply these rule before partition prune?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]