NobiGo commented on code in PR #3267:
URL: https://github.com/apache/calcite/pull/3267#discussion_r1230505997
##########
core/src/test/java/org/apache/calcite/rex/RexProgramTest.java:
##########
@@ -1604,6 +1604,48 @@ private void checkExponentialCnf(int n) {
"true");
}
+ /** Unit test for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5780">[CALCITE-5780]
+ * Always-true OR expressions contain reverse order comparison
+ * should be simplified to TRUE</a>. */
+ @Test void testSimplifyOrTermsWithReverseOrderComparison() {
+ final RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ final RelDataType rowType = typeFactory.builder()
+ .add("a", intType).nullable(true)
+ .build();
+
+ final RexDynamicParam range = rexBuilder.makeDynamicParam(rowType, 0);
+ final RexNode aRef = rexBuilder.makeFieldAccess(range, 0);
+
+ // "1 > a or 1 <= a or a is null" ==> "true"
+ checkSimplifyFilter(
+ or(gt(literal(1), aRef),
+ le(literal(1), aRef),
+ isNull(aRef)),
+ "true");
+
+ // "1 <= a or 1 > a or a is null" ==> "true"
+ checkSimplifyFilter(
+ or(le(literal(1), aRef),
+ gt(literal(1), aRef),
+ isNull(aRef)),
+ "true");
+
+ // "a is null 1 > a or 1 <= a" ==> "true"
Review Comment:
Should be `"a is null or 1 > a or 1 <= a" ==> "true"`
##########
core/src/test/java/org/apache/calcite/rex/RexProgramTest.java:
##########
@@ -1604,6 +1604,48 @@ private void checkExponentialCnf(int n) {
"true");
}
+ /** Unit test for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5780">[CALCITE-5780]
+ * Always-true OR expressions contain reverse order comparison
+ * should be simplified to TRUE</a>. */
+ @Test void testSimplifyOrTermsWithReverseOrderComparison() {
+ final RelDataType intType = typeFactory.createSqlType(SqlTypeName.INTEGER);
+ final RelDataType rowType = typeFactory.builder()
Review Comment:
According to the code change, Maybe `a is not null` should be covered too.
--
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]