LakeShen commented on code in PR #3316:
URL: https://github.com/apache/calcite/pull/3316#discussion_r1279128197
##########
core/src/test/java/org/apache/calcite/rex/RexProgramTest.java:
##########
@@ -801,6 +804,17 @@ private void checkExponentialCnf(int n) {
and(eRef,
or(fRef,
and(gRef, or(trueLiteral, falseLiteral)))))))));
+
Review Comment:
> When I try the `testCnfExponential` test with `HashMap` and
`LinkedHashMap`, it passes in both cases, am I missing something?
Hi @asolimando , testCnfExponential method doesn't call
RexUtil.CnfHelper#commonFactors, and the out-of-order situation only occurs in
some cases. In my PR test case, the following operation reproduces 100% of the
out-of-order situation:
1. use HashMap
2. change the exprected result of my test case to :
```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)))))"
```
3. Separate Run and Debug RexProgramTest#testPullFactors, directly run
single test can pass, Debug single test will give an error.
I see the underlying RexNode HashCode is different, currently I am
investigating why run and Debug, For the same RexNode, the hashCode is
different. In HashMap,the hashcode affects the order in which the values method
returns results.
Change the HashMap to LinkedHashMap,the values method returns results in a
deterministic order,it no longer has the possibility of being out of order.What
do you think
--
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]