englefly commented on code in PR #49774:
URL: https://github.com/apache/doris/pull/49774#discussion_r2086505589


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/ExtractCommonFactorRule.java:
##########
@@ -87,17 +88,16 @@ private static Expression 
extractCommonFactor(CompoundPredicate originExpr) {
 
         // combine and delete some boolean literal predicate
         // e.g. (a and true) -> true
-        Expression simplified = 
ExpressionUtils.combineAsLeftDeepTree(originExpr.getClass(), flatten);
+        Expression simplified = ExpressionUtils.compound(originExpr instanceof 
And, flatten);
         if (!(simplified instanceof CompoundPredicate)) {
             return simplified;
         }
 
         // separate two levels CompoundPredicate to partitions
         // e.g. ((a and (b or c)) and c) -> [[a], [b, c], c]
-        CompoundPredicate leftDeapTree = (CompoundPredicate) simplified;
         ImmutableSet.Builder<List<Expression>> partitionsBuilder
-                = ImmutableSet.builderWithExpectedSize(flatten.size());
-        for (Expression onPartition : ExpressionUtils.extract(leftDeapTree)) {
+                = 
ImmutableSet.builderWithExpectedSize(simplified.children().size());

Review Comment:
   simplified.children().size() <= flatten.size()
   ExpressionUtils.compound() does not extract conjuct/disjunct recursively 



##########
regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query13.out:
##########
@@ -20,7 +20,7 @@ PhysicalResultSink
 ----------------------------PhysicalProject
 ------------------------------PhysicalOlapScan[store]
 ------------------------PhysicalProject
---------------------------filter(OR[AND[(customer_demographics.cd_marital_status
 = 'D'),(customer_demographics.cd_education_status = 
'Unknown')],AND[(customer_demographics.cd_marital_status = 
'S'),(customer_demographics.cd_education_status = 
'College')],AND[(customer_demographics.cd_marital_status = 
'M'),(customer_demographics.cd_education_status = '4 yr Degree')]] and 
cd_education_status IN ('4 yr Degree', 'College', 'Unknown') and 
cd_marital_status IN ('D', 'M', 'S'))
+--------------------------filter(OR[AND[(customer_demographics.cd_marital_status
 = 'S'),(customer_demographics.cd_education_status = 
'College')],AND[(customer_demographics.cd_marital_status = 
'M'),(customer_demographics.cd_education_status = '4 yr 
Degree')],AND[(customer_demographics.cd_marital_status = 
'D'),(customer_demographics.cd_education_status = 'Unknown')]] and 
cd_education_status IN ('4 yr Degree', 'College', 'Unknown') and 
cd_marital_status IN ('D', 'M', 'S'))

Review Comment:
   please check that we could print the CompoundPredicate.shapeInfo() in stable 
order



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

Reply via email to