singhpk234 commented on code in PR #6190:
URL: https://github.com/apache/iceberg/pull/6190#discussion_r1022261543
##########
spark/v3.1/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java:
##########
@@ -70,9 +72,25 @@ public static Object convert(Type type, Object object) {
return convertedMap;
case DATE:
- return DateTimeUtils.fromJavaDate((Date) object);
+ // if spark.sql.datetime.java8API.enabled is set to true,
java.time.LocalDate
+ // for Spark SQL DATE type otherwise java.sql.Date is returned.
+ if (object instanceof Date) {
+ return DateTimeUtils.fromJavaDate((Date) object);
+ } else if (object instanceof LocalDate) {
+ return DateTimeUtils.localDateToDays((LocalDate) object);
+ } else {
+ throw new UnsupportedOperationException("Not a supported date class:
" + object);
+ }
Review Comment:
DateTimeUtils#anyToDays & DateTimeUtils#anyToMicros utils were introduced at
part of this [commit](anyToMicros) of 3.3.0 hence not present here.
Since the above two utils do a scala `match` without fallback if none of the
scenarios matched, added UnsupportedOperationException here.
--
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]