chunweilei commented on a change in pull request #1818: [CALCITE-3809]
RexSimplify simplifies nondeterministic function incorrectly
URL: https://github.com/apache/calcite/pull/1818#discussion_r382881401
##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -323,7 +323,7 @@ private RexNode simplifyComparison(RexCall e, RexUnknownAs
unknownAs) {
// Simplify "x <op> x"
final RexNode o0 = operands.get(0);
final RexNode o1 = operands.get(1);
- if (o0.equals(o1)) {
+ if (o0.equals(o1) && RexUtil.isDeterministic(o0)) {
Review comment:
Thank you for your clarification. I kind of understand your point. But I am
not convinced. Currently, you can find several places in RexSimplify where
```RexUtil.isDeterministic``` is used[1][2][3], which I think is necessary. Do
they ruin the performance of RexSimplify for valid deterministic cases? I don't
think so.
Now for the 1st question, it can be simplified though non-deterministic
functions exist. For instance, ```AND(rand()=rand(), true, true)``` can be
simplified to ```rand()=rand()```.
[1]https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L1385
[2]https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L1542
[3]https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L2251
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services