kangkaisen commented on a change in pull request #2821: The new materialized view selector URL: https://github.com/apache/incubator-doris/pull/2821#discussion_r375288106
########## File path: fe/src/main/java/org/apache/doris/planner/OlapScanNode.java ########## @@ -497,4 +596,108 @@ public static OlapScanNode createOlapScanNodeByLocation( return olapScanNode; } + + public void collectColumns(Analyzer analyzer, Set<String> equivalenceColumns, Set<String> unequivalenceColumns) { + // 1. Get columns which has predicate on it. + for (Expr expr : conjuncts) { + if (!isPredicateUsedForPrefixIndex(expr, false)) { + continue; + } + for (SlotDescriptor slot : desc.getMaterializedSlots()) { + if (expr.isBound(slot.getId())) { + if (!isEquivalenceExpr(expr)) { + unequivalenceColumns.add(slot.getColumn().getName()); + } else { + equivalenceColumns.add(slot.getColumn().getName()); + } + break; + } + } + } + + // 2. Equal join predicates when pushing inner child. + List<Expr> eqJoinPredicate = analyzer.getEqJoinConjuncts(desc.getId()); + for (Expr expr : eqJoinPredicate) { + if (!isPredicateUsedForPrefixIndex(expr, true)) { + continue; + } + for (SlotDescriptor slot : desc.getMaterializedSlots()) { + Preconditions.checkState(expr.getChildren().size() == 2); + for (Expr child : expr.getChildren()) { + if (child.isBound(slot.getId())) { + equivalenceColumns.add(slot.getColumn().getName()); + break; + } + } + } + } + } + + Review comment: I think we would better move following function to Expr related class, and change the method name more general for `xxxForPrefixIndex` methods. Because I think these function is useful when we implement new Cascades query optimizer. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org