rdblue commented on code in PR #7886:
URL: https://github.com/apache/iceberg/pull/7886#discussion_r1240436626
##########
spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/TestSparkV2Filters.java:
##########
@@ -264,4 +288,198 @@ public void testNotIn() {
Expressions.and(Expressions.notNull("col"), Expressions.notIn("col",
1, 2));
Assert.assertEquals("Expressions should match", expected.toString(),
actual.toString());
}
+
+ @Test
+ public void testYear() {
+ ScalarFunction<Integer> dateToYear = new
YearsFunction.DateToYearsFunction();
+ UserDefinedScalarFunc udf =
+ new UserDefinedScalarFunc(
+ dateToYear.name(),
+ dateToYear.canonicalName(),
+ expressions(FieldReference.apply("col1")));
+ testUDF(udf, Expressions.year("col1"), 2021, DataTypes.IntegerType);
+ }
+
+ @Test
+ public void testMonth() {
+ ScalarFunction<Integer> dateToMonth = new
MonthsFunction.DateToMonthsFunction();
+ UserDefinedScalarFunc udf =
+ new UserDefinedScalarFunc(
+ dateToMonth.name(),
+ dateToMonth.canonicalName(),
+ expressions(FieldReference.apply("col1")));
+ testUDF(udf, Expressions.month("col1"), 5, DataTypes.IntegerType);
+ }
+
+ @Test
+ public void testDay() {
+ ScalarFunction<Integer> dateToDay = new DaysFunction.DateToDaysFunction();
+ UserDefinedScalarFunc udf =
+ new UserDefinedScalarFunc(
+ dateToDay.name(), dateToDay.canonicalName(),
expressions(FieldReference.apply("col1")));
+ testUDF(udf, Expressions.day("col1"), 20, DataTypes.IntegerType);
Review Comment:
Here as well, we may want to allow comparison with a string date.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]