liyafan82 commented on a change in pull request #2098:
URL: https://github.com/apache/calcite/pull/2098#discussion_r468445089
##########
File path: core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
##########
@@ -2634,6 +2634,127 @@ private static String getString(ImmutableMap<RexNode,
RexNode> map) {
assertThat(simplifiedExpr, is(origExpr));
}
+ @Test void testSimplifyInValues() {
+ RexNode a = vIntNotNull(1);
+ RexNode literal1 = rexBuilder.makeLiteral(1, a.getType(), true);
+ RexNode literal2 = rexBuilder.makeLiteral(2, a.getType(), true);
+ RexNode literal3 = rexBuilder.makeLiteral(3, a.getType(), true);
+ RexNode literal4 = rexBuilder.makeLiteral(4, a.getType(), true);
+ RexNode literal5 = rexBuilder.makeLiteral(5, a.getType(), true);
+ RexNode literal6 = rexBuilder.makeLiteral(6, a.getType(), true);
+
+ // expr: a in (1, 2, 3, 4, 5)
+ RexNode expr = rexBuilder.makeCall(
+ SqlStdOperatorTable.IN, a, literal1, literal2, literal3, literal4,
literal5);
+ // expected: a >= 1 and a <= 5
+ RexNode expected = rexBuilder.makeCall(SqlStdOperatorTable.AND,
+ rexBuilder.makeCall(SqlStdOperatorTable.GREATER_THAN_OR_EQUAL, a,
literal1),
+ rexBuilder.makeCall(SqlStdOperatorTable.LESS_THAN_OR_EQUAL, a,
literal5));
Review comment:
@vlsi Revised accordingly, and the tests look much clearer. Thanks a lot
for your good suggestion.
----------------------------------------------------------------
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]