[ https://issues.apache.org/jira/browse/HIVE-28518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17880956#comment-17880956 ]
Gopinath commented on HIVE-28518: --------------------------------- With below changes , Same repro steps completed successfully. {noformat} ggangadharan@Workbench hive % git diff iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergTimestampObjectInspectorHive3.java diff --git a/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergTimestampObjectInspectorHive3.java b/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergTimestampObjectInspectorHive3.java index 86ecc929a5..4a2d2ed44c 100644 --- a/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergTimestampObjectInspectorHive3.java +++ b/iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergTimestampObjectInspectorHive3.java @@ -20,6 +20,7 @@ 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; @@ -55,7 +56,13 @@ public Timestamp getPrimitiveJavaObject(Object o) { if (o == null) { return null; } - LocalDateTime time = (LocalDateTime) o; + LocalDateTime time; + if (o instanceof OffsetDateTime) { + OffsetDateTime offsetDateTime = (OffsetDateTime) o; + time = offsetDateTime.toLocalDateTime(); + } else { + time = (LocalDateTime) o; + } return Timestamp.ofEpochMilli(time.toInstant(ZoneOffset.UTC).toEpochMilli(), time.getNano()); }ggangadharan@Workbench hive % {noformat} If there's no objections , i would like to work on this ticket. > Hive in-place migration to iceberg fails when there is a timestamp column > ------------------------------------------------------------------------- > > Key: HIVE-28518 > URL: https://issues.apache.org/jira/browse/HIVE-28518 > Project: Hive > Issue Type: Bug > Reporter: sachin > Priority: Major > > Hive in-place migration to iceberg fails when there is a timestamp column > Below are the steps to reproduce the issue. > {noformat} > CREATE EXTERNAL TABLE test(`id` int,`name` string,`dt` timestamp)STORED AS > PARQUET; > insert into test values (1, "test name" , cast('2024-08-09 14:08:26.326107' > as timestamp)); > select * from test; > ALTER TABLE test SET TBLPROPERTIES > ('storage_handler'='org.apache.iceberg.mr.hive.HiveIcebergStorageHandler', > 'format-version' = '2'); > select * from test; > {noformat} > Stack Trace - > {noformat} > Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: > java.lang.ClassCastException: java.time.OffsetDateTime cannot be cast to > java.time.LocalDateTime > at > org.apache.hadoop.hive.ql.exec.ListSinkOperator.process(ListSinkOperator.java:98) > at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:888) > at > org.apache.hadoop.hive.ql.exec.SelectOperator.process(SelectOperator.java:94) > at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:888) > at > org.apache.hadoop.hive.ql.exec.TableScanOperator.process(TableScanOperator.java:173) > at > org.apache.hadoop.hive.ql.exec.FetchOperator.pushRow(FetchOperator.java:545) > at > org.apache.hadoop.hive.ql.exec.FetchOperator.pushRow(FetchOperator.java:537) > at > org.apache.hadoop.hive.ql.exec.FetchTask.executeInner(FetchTask.java:194) > ... 55 more > Caused by: java.lang.ClassCastException: java.time.OffsetDateTime cannot be > cast to java.time.LocalDateTime > at > org.apache.iceberg.mr.hive.serde.objectinspector.IcebergTimestampObjectInspectorHive3.getPrimitiveJavaObject(IcebergTimestampObjectInspectorHive3.java:58) > at > org.apache.iceberg.mr.hive.serde.objectinspector.IcebergTimestampObjectInspectorHive3.getPrimitiveWritableObject(IcebergTimestampObjectInspectorHive3.java:64) > at > org.apache.hadoop.hive.serde2.lazy.LazyUtils.writePrimitiveUTF8(LazyUtils.java:308) > at > org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.serialize(LazySimpleSerDe.java:308) > at > org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.serializeField(LazySimpleSerDe.java:263) > at > org.apache.hadoop.hive.serde2.DelimitedJSONSerDe.serializeField(DelimitedJSONSerDe.java:72) > at > org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.doSerialize(LazySimpleSerDe.java:247) > at > org.apache.hadoop.hive.serde2.AbstractEncodingAwareSerDe.serialize(AbstractEncodingAwareSerDe.java:53) > at > org.apache.hadoop.hive.serde2.DefaultFetchFormatter.convert(DefaultFetchFormatter.java:67) > at > org.apache.hadoop.hive.serde2.DefaultFetchFormatter.convert(DefaultFetchFormatter.java:36) > at > org.apache.hadoop.hive.ql.exec.ListSinkOperator.process(ListSinkOperator.java:94) > ... 62 more{noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)