liyafan82 commented on a change in pull request #2098:
URL: https://github.com/apache/calcite/pull/2098#discussion_r468519527
##########
File path: core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
##########
@@ -2634,6 +2634,86 @@ private static String getString(ImmutableMap<RexNode,
RexNode> map) {
assertThat(simplifiedExpr, is(origExpr));
}
+ @Test void testSimplifyInValues() {
+ RexNode a = vIntNotNull(1);
+ RexNode literal1 = literal(1);
+ RexNode literal2 = literal(2);
+ RexNode literal3 = literal(3);
+ RexNode literal4 = literal(4);
+ RexNode literal5 = literal(5);
+ RexNode literal6 = literal(6);
+
+ // expr: a in (1, 2, 3, 4, 5)
+ RexNode expr = in(a, literal1, literal2, literal3, literal4, literal5);
+ // expected: a >= 1 and a <= 5
+ RexNode expected = and(ge(a, literal1), le(a, literal5));
+ RexNode simplifiedExpr = simplify.simplifyUnknownAs(expr,
RexUnknownAs.UNKNOWN);
+ assertThat(simplifiedExpr, is(expected));
Review comment:
Thanks for the good suggestion, and thanks for the explanation.
I have revised the PR accordingly.
----------------------------------------------------------------
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]