LakeShen commented on code in PR #3316:
URL: https://github.com/apache/calcite/pull/3316#discussion_r1279061424


##########
core/src/test/java/org/apache/calcite/rex/RexProgramTest.java:
##########
@@ -801,6 +808,40 @@ private void checkExponentialCnf(int n) {
                         and(eRef,
                             or(fRef,
                                and(gRef, or(trueLiteral, falseLiteral)))))))));
+
+    // In order to test the pullFactors RexNode operands in deterministic order
+    checkPullFactors(
+        or(
+            and(eq(aRef, bRef), eq(jRef, literal("Brand#12")), ge(hRef, 
literal(1)),
+                le(hRef, literal(11)), cRef, rexBuilder.makeIn(
+                    iRef, ImmutableList.of(literal("AIR"), literal("AIR 
REG"))),
+                rexBuilder.makeIn(
+                    kRef, ImmutableList.of(literal("SM BOX"),
+                    literal("SM CASE"), literal("SM PACK"), literal("SM 
PKG")))),
+
+            and(eq(aRef, bRef), eq(jRef, literal("Brand#13")), ge(hRef, 
literal(10)),
+                le(hRef, literal(20)), cRef, rexBuilder.makeIn(
+                    iRef, ImmutableList.of(literal("AIR"), literal("AIR 
REG"))),
+                rexBuilder.makeIn(
+                    kRef, ImmutableList.of(literal("MED BOX"),
+                    literal("MED CASE"), literal("MED PACK"), literal("MED 
PKG")))),
+
+            and(eq(aRef, bRef), eq(jRef, literal("Brand#14")), ge(hRef, 
literal(20)),
+                le(hRef, literal(30)), cRef, rexBuilder.makeIn(
+                    iRef, ImmutableList.of(literal("AIR"), literal("AIR 
REG"))),
+                rexBuilder.makeIn(
+                    kRef, ImmutableList.of(literal("LG BOX"),
+                    literal("LG CASE"), literal("LG PACK"), literal("LG 
PKG"))))),
+
+        "AND(=(?0.a, ?0.b), ?0.c, "
+            + "SEARCH(?0.i, Sarg['AIR':CHAR(7), 'AIR REG']:CHAR(7)), "
+            + "OR(AND(=(?0.j, 'Brand#12'), >=(?0.h, 1), <=(?0.h, 11),"

Review Comment:
   > The PR looks good.
   > 
   > @LakeShen I have a small question. If it's out of order, what might it 
look like?
   
   Hi @JiajunBernoulli ,I have reproduced it locally using my test case.
   Sometimes the RexNode is :
   ```sql
   AND(=(?0.a, ?0.b), SEARCH(?0.i, Sarg['AIR':CHAR(7), 'AIR REG']:CHAR(7)), 
?0.c, OR(AND(=(?0.j, 'Brand#12'), >=(?0.h, 1), <=(?0.h, 11), SEARCH(?0.k, 
Sarg['SM BOX':CHAR(7), 'SM CASE', 'SM PACK', 'SM PKG':CHAR(7)]:CHAR(7))), 
AND(=(?0.j, 'Brand#13'), >=(?0.h, 10), <=(?0.h, 20), SEARCH(?0.k, Sarg['MED 
BOX':CHAR(8), 'MED CASE', 'MED PACK', 'MED PKG':CHAR(8)]:CHAR(8))), AND(=(?0.j, 
'Brand#14'), >=(?0.h, 20), <=(?0.h, 30), SEARCH(?0.k, Sarg['LG BOX':CHAR(7), 
'LG CASE', 'LG PACK', 'LG PKG':CHAR(7)]:CHAR(7)))))
   ```
   Sometimes the RexNode is :
   ```sql
   AND(?0.c, SEARCH(?0.i, Sarg['AIR':CHAR(7), 'AIR REG']:CHAR(7)), =(?0.a, 
?0.b), OR(AND(=(?0.j, 'Brand#12'), >=(?0.h, 1), <=(?0.h, 11), SEARCH(?0.k, 
Sarg['SM BOX':CHAR(7), 'SM CASE', 'SM PACK', 'SM PKG':CHAR(7)]:CHAR(7))), 
AND(=(?0.j, 'Brand#13'), >=(?0.h, 10), <=(?0.h, 20), SEARCH(?0.k, Sarg['MED 
BOX':CHAR(8), 'MED CASE', 'MED PACK', 'MED PKG':CHAR(8)]:CHAR(8))), AND(=(?0.j, 
'Brand#14'), >=(?0.h, 20), <=(?0.h, 30), SEARCH(?0.k, Sarg['LG BOX':CHAR(7), 
'LG CASE', 'LG PACK', 'LG PKG':CHAR(7)]:CHAR(7)))))
   
   ```



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

Reply via email to