Aitozi commented on code in PR #21622:
URL: https://github.com/apache/flink/pull/21622#discussion_r1111272704
##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/utils/RexNodeExtractorTest.scala:
##########
@@ -721,6 +722,70 @@ class RexNodeExtractorTest extends RexNodeTestBase {
}
}
+ @Test
+ def testExtractPartitionPredicateList(): Unit = {
+ val doubleType: RelDataType =
+ typeFactory.createFieldTypeFromLogicalType(new DoubleType(false))
+
+ val decimalType: RelDataType =
+ typeFactory.createFieldTypeFromLogicalType(new DecimalType(4, 3))
+
+ val rand =
+ rexBuilder.makeCall(FlinkSqlOperatorTable.RAND,
rexBuilder.makeLiteral(321, doubleType, true))
+ val c1 = rexBuilder.makeCall(
+ SqlStdOperatorTable.LESS_THAN_OR_EQUAL,
+ rand,
+ rexBuilder.makeLiteral(new BigDecimal(0.001), decimalType, true))
+ val (p, nonP) = RexNodeExtractor.extractPartitionPredicateList(
+ c1,
+ -1,
+ Array("a", "b", "p"),
+ rexBuilder,
+ Array("p"))
+ Assert.assertTrue(p.isEmpty)
+ Assert.assertTrue(nonP.nonEmpty)
+ }
+
+ @Test
+ def testExtractPartitionPredicateList2(): Unit = {
+ val stringType = typeFactory.createFieldTypeFromLogicalType(new
VarCharType())
+
+ val partition = rexBuilder.makeLiteral("1984")
+ val inputRef = rexBuilder.makeInputRef(stringType, 2)
+ val c1 = rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, inputRef,
partition)
+ val (p, nonP) = RexNodeExtractor.extractPartitionPredicateList(
+ c1,
+ -1,
+ Array("a", "b", "p"),
+ rexBuilder,
+ Array("p"))
+ Assert.assertTrue(p.nonEmpty)
+ Assert.assertTrue(nonP.isEmpty)
+ }
+
+ @Test
+ def testExtractPartitionPredicateList3(): Unit = {
+ val intType = typeFactory.createFieldTypeFromLogicalType(new IntType())
+ val decimalType: RelDataType =
+ typeFactory.createFieldTypeFromLogicalType(new DecimalType(4, 3))
+
+ val inputRef = rexBuilder.makeInputRef(intType, 2)
+ val rand =
+ rexBuilder.makeCall(FlinkSqlOperatorTable.RAND, inputRef)
+ val c1 = rexBuilder.makeCall(
+ SqlStdOperatorTable.LESS_THAN_OR_EQUAL,
+ rand,
+ rexBuilder.makeLiteral(new BigDecimal(0.001), decimalType, true))
+ val (p, nonP) = RexNodeExtractor.extractPartitionPredicateList(
+ c1,
+ -1,
+ Array("a", "b", "p"),
+ rexBuilder,
+ Array("p"))
+ Assert.assertTrue(p.isEmpty)
+ Assert.assertTrue(nonP.isEmpty)
+ }
Review Comment:
I combine the three test to two, and added some comments.
--
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]