[
https://issues.apache.org/jira/browse/CALCITE-4256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17195960#comment-17195960
]
Thomas Rebele commented on CALCITE-4256:
----------------------------------------
The function RexUtil#flattenAnd removes the AND and the second comparison. It
adds all RexNodes of the AND into a set. However, as the two RexNodes for the
RAND_INTEGER call are considered equivalent, one of them gets removed. So it
seems to me that RexUtil#flattenAnd needs to be adapted, too. Is there already
a method that checks if two RexNode expressions are equivalent, taking
non-deterministic function calls into account?
> RexSimplify should not simplify P AND P to P, if it contains a call to RAND
> or RAND_INTEGER
> -------------------------------------------------------------------------------------------
>
> Key: CALCITE-4256
> URL: https://issues.apache.org/jira/browse/CALCITE-4256
> Project: Calcite
> Issue Type: Bug
> Reporter: Thomas Rebele
> Priority: Major
>
> Example: RAND_INTEGER() = 1 AND RAND_INTEGER() = 1 is false with a higher
> probability than RAND_INTEGER() = 1
> Here a test case for RexProgramTest:
> {code}
> @Test void testSimplifyRandomAnd() {
> checkSimplifyUnchanged(
> and(
> eq(rexBuilder.makeCall(SqlStdOperatorTable.RAND_INTEGER),
> literal(1)),
> eq(rexBuilder.makeCall(SqlStdOperatorTable.RAND_INTEGER),
> literal(1))
> ));
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)