TsReaper commented on a change in pull request #14243:
URL: https://github.com/apache/flink/pull/14243#discussion_r531457371
##########
File path:
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/utils/ColumnIntervalUtilTest.scala
##########
@@ -189,4 +193,85 @@ class ColumnIntervalUtilTest {
)
}
+ @Test
+ def testGetColumnIntervalWithFilter(): Unit = {
+ val typeFactory: FlinkTypeFactory = new FlinkTypeFactory(new
FlinkTypeSystem)
+ val rexBuilder: RexBuilder = new FlinkRexBuilder(typeFactory)
+
+ // ($1 >= 1 and $1 < 10) or (not($1 > 5)
+ val predicate = rexBuilder.makeCall(
+ SqlStdOperatorTable.OR,
+ rexBuilder.makeCall(
+ SqlStdOperatorTable.AND,
+ rexBuilder.makeCall(
+ SqlStdOperatorTable.GREATER_THAN_OR_EQUAL,
+
rexBuilder.makeInputRef(typeFactory.createSqlType(SqlTypeName.BIGINT), 1),
+ rexBuilder.makeBigintLiteral(java.math.BigDecimal.valueOf(1))),
+ rexBuilder.makeCall(
+ SqlStdOperatorTable.LESS_THAN,
+
rexBuilder.makeInputRef(typeFactory.createSqlType(SqlTypeName.BIGINT), 1),
+ rexBuilder.makeBigintLiteral(java.math.BigDecimal.valueOf(10)))),
+ rexBuilder.makeCall(
+ SqlStdOperatorTable.NOT,
+ rexBuilder.makeCall(
+ SqlStdOperatorTable.GREATER_THAN,
+
rexBuilder.makeInputRef(typeFactory.createSqlType(SqlTypeName.BIGINT), 1),
+ rexBuilder.makeBigintLiteral(java.math.BigDecimal.valueOf(5))))
+ )
+
+ assertEquals(
+ toBigDecimalInterval(ValueInterval.apply(null, 10L, includeUpper =
false)),
+ ColumnIntervalUtil.getColumnIntervalWithFilter(
+ None,
+ predicate,
+ 1,
+ rexBuilder))
+
+ assertEquals(
+ toBigDecimalInterval(ValueInterval.apply(3L, 8L, includeLower = false,
includeUpper = false)),
+ ColumnIntervalUtil.getColumnIntervalWithFilter(
+ Some(toBigDecimalInterval(
+ ValueInterval.apply(3L, 8L, includeLower = false, includeUpper =
false))),
+ predicate,
+ 1,
+ rexBuilder))
+
Review comment:
Add a test for intersecting but not containing interval?
```scala
assertEquals(
toBigDecimalInterval(ValueInterval.apply(3L, 12L, includeLower = false,
includeUpper = false)),
ColumnIntervalUtil.getColumnIntervalWithFilter(
Some(toBigDecimalInterval(
ValueInterval.apply(3L, 10L, includeLower = false, includeUpper =
false))),
predicate,
1,
rexBuilder))
```
----------------------------------------------------------------
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]