Gezi-lzq commented on issue #11899: URL: https://github.com/apache/iceberg/issues/11899#issuecomment-2572232239
> I think the issue here is that the Copy constructor for GenericRecord does not do type checking. The accessor is failing because the Generic record has an illegal object in it. We should have failed when the LocalDateTime is inserted because that is not a valid Iceberg type that can be in a struct and doesn't match the Iceberg type of Timestamp (Long microseconds from epoch).我认为这里的问题是 GenericRecord 的拷贝构造函数没有进行类型检查。访问器失败是因为 Generic 记录中包含了一个非法的对象。当我们插入 LocalDateTime 时本应失败,因为 LocalDateTime 不是可以在 struct 中使用的有效 Iceberg 类型,且与 Timestamp 类型(从 epoch 开始的长整型微秒数)不匹配。 > > See here for the Java Classes used in the reference lib for various Iceberg Types在这里查看用于各种 Iceberg 类型的相关 lib 中的 Java 类 > > https://github.com/apache/iceberg/blob/821aec32bb9be28d9c1905f772d9e3101cc98d9e/api/src/main/java/org/apache/iceberg/types/Type.java#L31-L49 > > So to fix this you need to just convert LocalDateTime into the actual Iceberg Type before putting it in the generic record.所以你需要在将其放入通用记录之前,将 LocalDateTime 转换为实际的 Iceberg 类型。 > > ```java > LocalDateTime val = LocalDateTime.parse("2024-10-08T13:18:20.053"); > Long epochMicros = DateTimeUtil.microsFromTimestamp(val) > Record rec = GenericRecord.create(schema).copy( > ImmutableMap.of( > "year", epochMicros, > "day", epochMicros)); > ``` @RussellSpitzer I noticed that in Kafka connect, the Value values corresponding to TimestampType are all LocalDateTime. Is there a problem with this approach -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org