You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/10/17 09:29:33 UTC

[GitHub] [doris] wangshuo128 opened a new pull request, #13416: [Feature](Nereids) Support materialized index selection.

wangshuo128 opened a new pull request, #13416:
URL: https://github.com/apache/doris/pull/13416

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] wangshuo128 commented on a diff in pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #13416:
URL: https://github.com/apache/doris/pull/13416#discussion_r1003970016


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java:
##########
@@ -164,30 +164,31 @@ public long getSelectedIndexId() {
         return selectedIndexId;
     }
 
-    public boolean isRollupSelected() {
-        return rollupSelected;
+    public boolean isIndexSelected() {
+        return indexSelected;
     }
 
     public PreAggStatus getPreAggStatus() {
         return preAggStatus;
     }
 
     /**
-     * Should apply {@link SelectRollupWithAggregate} or not.
+     * Should apply {@link SelectMaterializedIndexWithAggregate} or not.
      */
-    public boolean shouldSelectRollup() {
+    public boolean shouldSelectIndex() {

Review Comment:
   This was to do two things:
   1. judge `indexSelected` is true or false
   2. make sure the keys type of the OLAP table is `DUP_KEYS`, `UNIQUE_KEYS`, or `AGG_KEYS`,  but it should not be `PRIMARY_KEYS`.  Even if it seems `PRIMARY_KEYS` is not used, it's safe to ensure the scope to apply materialized view selection rules is right.
   
   I would keep the getter method in of the status of `indexSelected` in `LogicalOlapScan` and move the condition of applying materialized view selection to the rule itself.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] wangshuo128 commented on a diff in pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #13416:
URL: https://github.com/apache/doris/pull/13416#discussion_r1003977525


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/mv/SelectMaterializedIndexWithoutAggregate.java:
##########
@@ -0,0 +1,147 @@
+// 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.rules.mv;
+
+import org.apache.doris.catalog.MaterializedIndex;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.rules.rewrite.RewriteRuleFactory;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.plans.PreAggStatus;
+import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
+import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+import java.util.List;
+import java.util.Set;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+/**
+ * Select materialized index, i.e., both for rollup and materialized view when aggregate is not present.
+ * <p>
+ * Scan OLAP table with aggregate is handled in {@link SelectMaterializedIndexWithAggregate}.
+ * <p>
+ * Note that we should first apply {@link SelectMaterializedIndexWithAggregate} and then
+ * {@link SelectMaterializedIndexWithoutAggregate}.
+ * Besides, these two rules should run in isolated batches, thus when enter this rule, it's guaranteed that there is
+ * no aggregation on top of the scan.
+ */
+public class SelectMaterializedIndexWithoutAggregate extends AbstractSelectMaterializedIndexRule
+        implements RewriteRuleFactory {
+
+    @Override
+    public List<Rule> buildRules() {
+        return ImmutableList.of(
+                // project with pushdown filter.
+                // Project(Filter(Scan))
+                logicalProject(logicalFilter(logicalOlapScan().whenNot(LogicalOlapScan::isIndexSelected)))
+                        .then(project -> {
+                            LogicalFilter<LogicalOlapScan> filter = project.child();
+                            LogicalOlapScan scan = filter.child();
+                            return project.withChildren(filter.withChildren(
+                                    select(scan, project::getInputSlots, filter::getConjuncts)));
+                        }).toRule(RuleType.MATERIALIZED_INDEX_PROJECT_FILTER_SCAN),
+
+                // project with filter that cannot be pushdown.
+                // Filter(Project(Scan))
+                logicalFilter(logicalProject(logicalOlapScan().whenNot(LogicalOlapScan::isIndexSelected)))
+                        .then(filter -> {
+                            LogicalProject<LogicalOlapScan> project = filter.child();
+                            LogicalOlapScan scan = project.child();
+                            return filter.withChildren(project.withChildren(
+                                    select(scan, project::getInputSlots, ImmutableList::of)
+                            ));
+                        }).toRule(RuleType.MATERIALIZED_INDEX_FILTER_PROJECT_SCAN),
+
+                // scan with filters could be pushdown.
+                // Filter(Scan)
+                logicalFilter(logicalOlapScan().whenNot(LogicalOlapScan::isIndexSelected))
+                        .then(filter -> {
+                            LogicalOlapScan scan = filter.child();
+                            return filter.withChildren(select(scan, ImmutableSet::of, filter::getConjuncts));
+                        })
+                        .toRule(RuleType.MATERIALIZED_INDEX_FILTER_SCAN),
+
+                // project and scan.
+                // Project(Scan)
+                logicalProject(logicalOlapScan().whenNot(LogicalOlapScan::isIndexSelected))
+                        .then(project -> {
+                            LogicalOlapScan scan = project.child();
+                            return project.withChildren(
+                                    select(scan, project::getInputSlots, ImmutableList::of));
+                        })
+                        .toRule(RuleType.MATERIALIZED_INDEX_PROJECT_SCAN),
+
+                // only scan.
+                logicalOlapScan()
+                        .whenNot(LogicalOlapScan::isIndexSelected)
+                        .then(scan -> select(scan, scan::getOutputSet, ImmutableList::of))
+                        .toRule(RuleType.MATERIALIZED_INDEX_SCAN)
+        );
+    }
+
+    /**
+     * Select materialized index when aggregate node is not present.
+     *
+     * @param scan Scan node.
+     * @param requiredScanOutputSupplier Supplier to get the required scan output.
+     * @param predicatesSupplier Supplier to get pushdown predicates.
+     * @return Result scan node.
+     */
+    private LogicalOlapScan select(
+            LogicalOlapScan scan,
+            Supplier<Set<Slot>> requiredScanOutputSupplier,
+            Supplier<List<Expression>> predicatesSupplier) {
+        switch (scan.getTable().getKeysType()) {
+            case AGG_KEYS:
+            case UNIQUE_KEYS:
+                OlapTable table = scan.getTable();
+                long baseIndexId = table.getBaseIndexId();
+                int baseIndexKeySize = table.getKeyColumnsByIndexId(table.getBaseIndexId()).size();
+                // No on aggregate on scan.

Review Comment:
   fixed
   



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Count.java:
##########
@@ -30,7 +31,7 @@
 import java.util.stream.Collectors;
 
 /** count agg function. */
-public class Count extends AggregateFunction implements AlwaysNotNullable {
+public class Count extends AggregateFunction implements UnaryExpression, AlwaysNotNullable {

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] wangshuo128 commented on a diff in pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #13416:
URL: https://github.com/apache/doris/pull/13416#discussion_r1000231427


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java:
##########
@@ -313,22 +312,13 @@ public PlanFragment visitPhysicalOlapScan(PhysicalOlapScan olapScan, PlanTransla
         tupleDescriptor.setRef(tableRef);
         olapScanNode.setSelectedPartitionIds(olapScan.getSelectedPartitionIds());

Review Comment:
   `olapScanNode` is the plan node in old planner.  `OlapScanNode.setXXX` is to set the result of nereids planner to `OlapScanNode` in old planner. 



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow commented on a diff in pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
morrySnow commented on code in PR #13416:
URL: https://github.com/apache/doris/pull/13416#discussion_r1003217319


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java:
##########
@@ -87,7 +87,7 @@ public LogicalOlapScan(RelationId id, Table table, List<String> qualifier,
         }
         this.partitionPruned = partitionPruned;
         this.candidateIndexIds = candidateIndexIds;
-        this.rollupSelected = rollupSelected;
+        this.indexSelected = rollupSelected;

Review Comment:
   ```suggestion
           this.indexSelected = indexSelected;
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Count.java:
##########
@@ -30,7 +31,7 @@
 import java.util.stream.Collectors;
 
 /** count agg function. */
-public class Count extends AggregateFunction implements AlwaysNotNullable {
+public class Count extends AggregateFunction implements UnaryExpression, AlwaysNotNullable {

Review Comment:
   when we use count(*), the count has no child, so maybe UnaryExpression is inappropriate



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/mv/SelectMaterializedIndexWithoutAggregate.java:
##########
@@ -0,0 +1,147 @@
+// 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.rules.mv;
+
+import org.apache.doris.catalog.MaterializedIndex;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.rules.rewrite.RewriteRuleFactory;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.plans.PreAggStatus;
+import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
+import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+import java.util.List;
+import java.util.Set;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+/**
+ * Select materialized index, i.e., both for rollup and materialized view when aggregate is not present.
+ * <p>
+ * Scan OLAP table with aggregate is handled in {@link SelectMaterializedIndexWithAggregate}.
+ * <p>
+ * Note that we should first apply {@link SelectMaterializedIndexWithAggregate} and then
+ * {@link SelectMaterializedIndexWithoutAggregate}.
+ * Besides, these two rules should run in isolated batches, thus when enter this rule, it's guaranteed that there is
+ * no aggregation on top of the scan.
+ */
+public class SelectMaterializedIndexWithoutAggregate extends AbstractSelectMaterializedIndexRule
+        implements RewriteRuleFactory {
+
+    @Override
+    public List<Rule> buildRules() {
+        return ImmutableList.of(
+                // project with pushdown filter.
+                // Project(Filter(Scan))
+                logicalProject(logicalFilter(logicalOlapScan().whenNot(LogicalOlapScan::isIndexSelected)))
+                        .then(project -> {
+                            LogicalFilter<LogicalOlapScan> filter = project.child();
+                            LogicalOlapScan scan = filter.child();
+                            return project.withChildren(filter.withChildren(
+                                    select(scan, project::getInputSlots, filter::getConjuncts)));
+                        }).toRule(RuleType.MATERIALIZED_INDEX_PROJECT_FILTER_SCAN),
+
+                // project with filter that cannot be pushdown.
+                // Filter(Project(Scan))
+                logicalFilter(logicalProject(logicalOlapScan().whenNot(LogicalOlapScan::isIndexSelected)))
+                        .then(filter -> {
+                            LogicalProject<LogicalOlapScan> project = filter.child();
+                            LogicalOlapScan scan = project.child();
+                            return filter.withChildren(project.withChildren(
+                                    select(scan, project::getInputSlots, ImmutableList::of)
+                            ));
+                        }).toRule(RuleType.MATERIALIZED_INDEX_FILTER_PROJECT_SCAN),
+
+                // scan with filters could be pushdown.
+                // Filter(Scan)
+                logicalFilter(logicalOlapScan().whenNot(LogicalOlapScan::isIndexSelected))
+                        .then(filter -> {
+                            LogicalOlapScan scan = filter.child();
+                            return filter.withChildren(select(scan, ImmutableSet::of, filter::getConjuncts));
+                        })
+                        .toRule(RuleType.MATERIALIZED_INDEX_FILTER_SCAN),
+
+                // project and scan.
+                // Project(Scan)
+                logicalProject(logicalOlapScan().whenNot(LogicalOlapScan::isIndexSelected))
+                        .then(project -> {
+                            LogicalOlapScan scan = project.child();
+                            return project.withChildren(
+                                    select(scan, project::getInputSlots, ImmutableList::of));
+                        })
+                        .toRule(RuleType.MATERIALIZED_INDEX_PROJECT_SCAN),
+
+                // only scan.
+                logicalOlapScan()
+                        .whenNot(LogicalOlapScan::isIndexSelected)
+                        .then(scan -> select(scan, scan::getOutputSet, ImmutableList::of))
+                        .toRule(RuleType.MATERIALIZED_INDEX_SCAN)
+        );
+    }
+
+    /**
+     * Select materialized index when aggregate node is not present.
+     *
+     * @param scan Scan node.
+     * @param requiredScanOutputSupplier Supplier to get the required scan output.
+     * @param predicatesSupplier Supplier to get pushdown predicates.
+     * @return Result scan node.
+     */
+    private LogicalOlapScan select(
+            LogicalOlapScan scan,
+            Supplier<Set<Slot>> requiredScanOutputSupplier,
+            Supplier<List<Expression>> predicatesSupplier) {
+        switch (scan.getTable().getKeysType()) {
+            case AGG_KEYS:
+            case UNIQUE_KEYS:
+                OlapTable table = scan.getTable();
+                long baseIndexId = table.getBaseIndexId();
+                int baseIndexKeySize = table.getKeyColumnsByIndexId(table.getBaseIndexId()).size();
+                // No on aggregate on scan.

Review Comment:
   ```suggestion
                   // No aggregation on scan.
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java:
##########
@@ -164,30 +164,31 @@ public long getSelectedIndexId() {
         return selectedIndexId;
     }
 
-    public boolean isRollupSelected() {
-        return rollupSelected;
+    public boolean isIndexSelected() {
+        return indexSelected;
     }
 
     public PreAggStatus getPreAggStatus() {
         return preAggStatus;
     }
 
     /**
-     * Should apply {@link SelectRollupWithAggregate} or not.
+     * Should apply {@link SelectMaterializedIndexWithAggregate} or not.
      */
-    public boolean shouldSelectRollup() {
+    public boolean shouldSelectIndex() {

Review Comment:
   do we need to remove this function and use isIndexSelected instead?



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow merged pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
morrySnow merged PR #13416:
URL: https://github.com/apache/doris/pull/13416


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] 924060929 commented on a diff in pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
924060929 commented on code in PR #13416:
URL: https://github.com/apache/doris/pull/13416#discussion_r999072231


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/mv/SelectMaterializedIndexWithAggregate.java:
##########
@@ -543,7 +398,7 @@ public CheckContext(LogicalOlapScan scan) {
                             )
                     ));

Review Comment:
   ```java
   Map<Boolean, Map<String, Column>> nameToColumnGroupingByIsKey
       = scan.getTable().getSchemaByIndexId(indexId)
           .collect(Collectors.groupingBy(
                   Column::isKey,
                   Collectors.toMap(Column::getName, Function.identity())
           ));



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java:
##########
@@ -313,22 +312,13 @@ public PlanFragment visitPhysicalOlapScan(PhysicalOlapScan olapScan, PlanTransla
         tupleDescriptor.setRef(tableRef);
         olapScanNode.setSelectedPartitionIds(olapScan.getSelectedPartitionIds());

Review Comment:
   olapScanNode should be immutable?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/mv/SelectMaterializedIndexWithAggregate.java:
##########
@@ -543,7 +398,7 @@ public CheckContext(LogicalOlapScan scan) {
                             )
                     ));

Review Comment:
   rename `checkHasNoValueTypeColumn` method to `disablePreAggIfContainsAnyValueColumn`



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] 924060929 commented on pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
924060929 commented on PR #13416:
URL: https://github.com/apache/doris/pull/13416#issuecomment-1288396572

   we should flat filter candidate index to refine code later.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13416:
URL: https://github.com/apache/doris/pull/13416#issuecomment-1288388202

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13416:
URL: https://github.com/apache/doris/pull/13416#issuecomment-1288388180

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] wangshuo128 commented on a diff in pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #13416:
URL: https://github.com/apache/doris/pull/13416#discussion_r1000229471


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/mv/SelectMaterializedIndexWithAggregate.java:
##########
@@ -543,7 +398,7 @@ public CheckContext(LogicalOlapScan scan) {
                             )
                     ));

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] wangshuo128 commented on a diff in pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #13416:
URL: https://github.com/apache/doris/pull/13416#discussion_r1003970016


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java:
##########
@@ -164,30 +164,31 @@ public long getSelectedIndexId() {
         return selectedIndexId;
     }
 
-    public boolean isRollupSelected() {
-        return rollupSelected;
+    public boolean isIndexSelected() {
+        return indexSelected;
     }
 
     public PreAggStatus getPreAggStatus() {
         return preAggStatus;
     }
 
     /**
-     * Should apply {@link SelectRollupWithAggregate} or not.
+     * Should apply {@link SelectMaterializedIndexWithAggregate} or not.
      */
-    public boolean shouldSelectRollup() {
+    public boolean shouldSelectIndex() {

Review Comment:
   This was to do two things:
   1. judge `indexSelected` is true or false
   2. make sure the keys type of the OLAP table is `DUP_KEYS`, `UNIQUE_KEYS`, or `AGG_KEYS`,  but it should not be `PRIMARY_KEYS`.  Even if it seems `PRIMARY_KEYS` is not used, it's safe to ensure the scope to apply materialized view selection rules is right.
   
   I would keep the getter method of the status of `indexSelected` in `LogicalOlapScan` and move the condition of applying materialized view selection to the rule itself.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] wangshuo128 commented on a diff in pull request #13416: [Feature](Nereids) Support materialized index selection.

Posted by GitBox <gi...@apache.org>.
wangshuo128 commented on code in PR #13416:
URL: https://github.com/apache/doris/pull/13416#discussion_r1003970016


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java:
##########
@@ -164,30 +164,31 @@ public long getSelectedIndexId() {
         return selectedIndexId;
     }
 
-    public boolean isRollupSelected() {
-        return rollupSelected;
+    public boolean isIndexSelected() {
+        return indexSelected;
     }
 
     public PreAggStatus getPreAggStatus() {
         return preAggStatus;
     }
 
     /**
-     * Should apply {@link SelectRollupWithAggregate} or not.
+     * Should apply {@link SelectMaterializedIndexWithAggregate} or not.
      */
-    public boolean shouldSelectRollup() {
+    public boolean shouldSelectIndex() {

Review Comment:
   This was to do two things:
   1. judge `indexSelected` is true or false
   2. make sure the keys type of the OLAP table is `DUP_KEYS`, `UNIQUE_KEYS`, or `AGG_KEYS`,  but it should not be `PRIMARY_KEYS`.  Even if it seems `PRIMARY_KEYS` is not used, it's safe to ensure the scope to apply materialized view selection rules is right.
   
   I'd unify `shouldSelectIndex()` and `isIndexSelected()` into one.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org