pvary commented on a change in pull request #1897:
URL: https://github.com/apache/iceberg/pull/1897#discussion_r540994252
##########
File path:
hive3/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergTimestampObjectInspectorHive3.java
##########
@@ -20,50 +20,38 @@
package org.apache.iceberg.mr.hive.serde.objectinspector;
import java.time.LocalDateTime;
-import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import org.apache.hadoop.hive.common.type.Timestamp;
import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
import
org.apache.hadoop.hive.serde2.objectinspector.primitive.AbstractPrimitiveJavaObjectInspector;
import
org.apache.hadoop.hive.serde2.objectinspector.primitive.TimestampObjectInspector;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
-public abstract class IcebergTimestampObjectInspectorHive3 extends
AbstractPrimitiveJavaObjectInspector
- implements TimestampObjectInspector {
+public class IcebergTimestampObjectInspectorHive3 extends
AbstractPrimitiveJavaObjectInspector
+ implements TimestampObjectInspector, WriteObjectInspector {
- private static final IcebergTimestampObjectInspectorHive3 INSTANCE_WITH_ZONE
=
- new IcebergTimestampObjectInspectorHive3() {
- @Override
- LocalDateTime toLocalDateTime(Object o) {
- return ((OffsetDateTime) o).toLocalDateTime();
- }
- };
+ private static final IcebergTimestampObjectInspectorHive3 INSTANCE = new
IcebergTimestampObjectInspectorHive3();
- private static final IcebergTimestampObjectInspectorHive3
INSTANCE_WITHOUT_ZONE =
- new IcebergTimestampObjectInspectorHive3() {
- @Override
- LocalDateTime toLocalDateTime(Object o) {
- return (LocalDateTime) o;
- }
- };
-
- public static IcebergTimestampObjectInspectorHive3 get(boolean adjustToUTC) {
- return adjustToUTC ? INSTANCE_WITH_ZONE : INSTANCE_WITHOUT_ZONE;
+ public static IcebergTimestampObjectInspectorHive3 get() {
+ return INSTANCE;
}
private IcebergTimestampObjectInspectorHive3() {
super(TypeInfoFactory.timestampTypeInfo);
}
-
- abstract LocalDateTime toLocalDateTime(Object object);
+ @Override
+ public LocalDateTime convert(Object o) {
+ return o == null ? null : LocalDateTime.ofEpochSecond(
+ ((TimestampWritableV2) o).getTimestamp().toEpochSecond(), 0,
ZoneOffset.UTC);
Review comment:
Do we lose nanos 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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]