XieJiann commented on code in PR #29609:
URL: https://github.com/apache/doris/pull/29609#discussion_r1444237599


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewRule.java:
##########
@@ -383,30 +396,87 @@ protected Expression rewriteExpression(Expression 
sourceExpressionsToWrite, Plan
      * For another example as following:
      * predicate a = b in mv, and a = b and c = d in query, the compensatory 
predicate is c = d
      */
-    protected SplitPredicate predicatesCompensate(StructInfo queryStructInfo, 
StructInfo viewStructInfo,
-            SlotMapping queryToViewSlotMapping) {
+    protected SplitPredicate predicatesCompensate(
+            StructInfo queryStructInfo,
+            StructInfo viewStructInfo,
+            SlotMapping queryToViewSlotMapping,
+            ComparisonResult comparisonResult,
+            CascadesContext cascadesContext
+    ) {
+        // viewEquivalenceClass to query based
+        SlotMapping viewToQuerySlotMapping = queryToViewSlotMapping.inverse();
+        final Set<Expression> equalCompensateConjunctions = 
compensateEquivalence(
+                queryStructInfo,
+                viewStructInfo,
+                viewToQuerySlotMapping,
+                comparisonResult);
+        // range compensate
+        final Set<Expression> rangeCompensatePredicates = 
compensateRangePredicate(
+                queryStructInfo,
+                viewStructInfo,
+                viewToQuerySlotMapping,
+                comparisonResult);
+        // residual compensate
+        final Set<Expression> residualCompensatePredicates = 
compensateResidualPredicate(
+                queryStructInfo,
+                viewStructInfo,
+                viewToQuerySlotMapping,
+                comparisonResult);
+        // if the join type in query and mv plan is different, we should check 
and add filter on mv to make
+        // the mv join type is accord with query
+        Set<Set<Slot>> viewNoNullableSlot = 
comparisonResult.getViewNoNullableSlot();
+        // check query is use the null reject slot which view comparison need
+        if (!viewNoNullableSlot.isEmpty()) {
+            Set<Expression> queryPulledUpPredicates = 
queryStructInfo.getPredicates().getPulledUpPredicates();
+            Set<Expression> nullRejectPredicates = 
ExpressionUtils.inferNotNull(queryPulledUpPredicates,
+                    cascadesContext);
+            if (nullRejectPredicates.isEmpty() || 
queryPulledUpPredicates.containsAll(nullRejectPredicates)) {
+                // query has not null reject predicates, so return
+                return SplitPredicate.empty();
+            }
+            Set<Expression> queryUsedRejectNullSlotsViewBased = 
nullRejectPredicates.stream()
+                    .map(expression -> 
TypeUtils.isNotNull(expression).orElse(null))
+                    .filter(Objects::nonNull)
+                    .map(expr -> ExpressionUtils.replace((Expression) expr,
+                            queryToViewSlotMapping.toSlotReferenceMap()))
+                    .collect(Collectors.toSet());
+            if (viewNoNullableSlot.stream().anyMatch(
+                    set -> Sets.intersection(set, 
queryUsedRejectNullSlotsViewBased).isEmpty())) {
+                return SplitPredicate.empty();
+            }

Review Comment:
   what is splitPredicate meanings



-- 
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-unsubscr...@doris.apache.org

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


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

Reply via email to