cloud-fan commented on a change in pull request #28197: [SPARK-31431][SQL] Add
CalendarInterval encoder support
URL: https://github.com/apache/spark/pull/28197#discussion_r409603011
##########
File path:
sql/core/src/test/java/test/org/apache/spark/sql/JavaDatasetSuite.java
##########
@@ -263,6 +264,70 @@ public void testSelect() {
selected.collectAsList());
}
+ @Test
+ public void testCalendarInterval() {
+ List<CalendarInterval> data = Arrays.asList(
+ new CalendarInterval(1, 2, 0),
+ new CalendarInterval(4, 5, 0),
+ null);
+ Dataset<CalendarInterval> ds =
+ spark.createDataset(data, Encoders.INTERVAL());
+
+ Dataset<String> selected =
+ ds.select(expr("value + interval 1
hour").cast("string")).as(Encoders.STRING());
+
+ Assert.assertEquals(
+ Arrays.asList("1 months 2 days 1 hours", "4 months 5 days 1 hours",
null),
+ selected.collectAsList());
+ }
+
+
+ public static class IntervalBean implements Serializable {
+ private CalendarInterval i;
Review comment:
can we test interval array as well?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]