yujun777 commented on code in PR #49851:
URL: https://github.com/apache/doris/pull/49851#discussion_r2055474834


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ExtractSingleTableExpressionFromDisjunction.java:
##########
@@ -137,6 +142,23 @@ private Optional<Expression> 
extractSingleTableExpression(Expression expr, Strin
         for (Expression conjunct : conjuncts) {
             if (isSingleTableExpression(conjunct, qualifier)) {
                 output.add(conjunct);
+            } else if (conjunct instanceof Or) {
+                List<Expression> disjuncts = 
ExpressionUtils.extractDisjunction(conjunct);
+                List<Expression> extracted = 
Lists.newArrayListWithExpectedSize(disjuncts.size());
+                boolean success = true;
+                for (Expression disjunct : disjuncts) {
+                    Optional<Expression> extractedDisjunct = 
extractSingleTableExpression(disjunct, qualifier);
+                    if (extractedDisjunct.isPresent()) {
+                        extracted.add(extractedDisjunct.get());
+                    } else {
+                        // extract failed
+                        success = false;
+                        break;
+                    }
+                }
+                if (success) {
+                    output.add(ExpressionUtils.or(extracted));

Review Comment:
   ExtractSingleTableExpressionFromDisjunction will add the extracted 
expression to the root expression,
   for example:  for expression E,  ExtractSingleTableExpressionFromDisjunction 
will rewrite it to `E and (table_1's expression)  and (table_2's expression) 
and (...)`.
   
   for  `[(expr1 or expr2) and (expr3 or expr4)] or [part1] or [part2]`,   for 
table t1, if it can extract from `(expr1 or expr2)`,   but it cann't extract 
from part1 and part2, then it will extract t1 will failed,   because for the OR 
expression, if any part of the OR extract failed, then the whole OR will 
extract failed.



-- 
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