rdblue commented on code in PR #7553:
URL: https://github.com/apache/iceberg/pull/7553#discussion_r1199093706
##########
spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/SparkValueConverter.java:
##########
@@ -72,9 +73,16 @@ public static Object convert(Type type, Object object) {
// for Spark SQL DATE type otherwise java.sql.Date is returned.
return DateTimeUtils.anyToDays(object);
case TIMESTAMP:
- // if spark.sql.datetime.java8API.enabled is set to true,
java.time.Instant
- // for Spark SQL TIMESTAMP type is returned otherwise
java.sql.Timestamp is returned.
- return DateTimeUtils.anyToMicros(object);
+ Types.TimestampType ts = (Types.TimestampType) type.asPrimitiveType();
+
+ if (ts.shouldAdjustToUTC()) {
+ // if spark.sql.datetime.java8API.enabled is set to true,
java.time.Instant
+ // for Spark SQL TIMESTAMP type is returned otherwise
java.sql.Timestamp is returned.
+ return DateTimeUtils.anyToMicros(object);
+ } else {
+ LocalDateTime ldt = (LocalDateTime) object;
+ return DateTimeUtils.localDateTimeToMicros(ldt);
Review Comment:
Why not just add `LocalDateTime` support to `anyToMicros`? That seems to
make more sense than assuming a `LocalDateTime` for `timestampntz`.
--
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]