pvary commented on a change in pull request #2254:
URL: https://github.com/apache/iceberg/pull/2254#discussion_r584042222
##########
File path:
mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergFilterFactory.java
##########
@@ -172,15 +171,24 @@ private static BigDecimal
hiveDecimalToBigDecimal(HiveDecimalWritable hiveDecima
return
hiveDecimalWritable.getHiveDecimal().bigDecimalValue().setScale(hiveDecimalWritable.scale());
}
+ // Hive uses `java.sql.Date.valueOf(lit.toString());` to convert a literal
to Date
+ // Which uses `java.util.Date()` internally to create the object and that
uses the TimeZone.getDefaultRef()
+ // To get back the expected date we have to use the LocalDate which gets rid
of the TimeZone misery as it uses
+ // the year/month/day to generate the object
private static int daysFromDate(Date date) {
- return DateTimeUtil.daysFromInstant(Instant.ofEpochMilli(date.getTime()));
+ return DateTimeUtil.daysFromDate(date.toLocalDate());
}
+ // Hive uses `java.sql.Timestamp.valueOf(lit.toString());` to convert a
literal to Timestamp
+ // Which again uses `java.util.Date()` internally to create the object which
uses the TimeZone.getDefaultRef()
+ // To get back the expected timestamp we have to use the LocalDateTime which
gets rid of the TimeZone misery
+ // as it uses the year/month/day/hour/min/sec/nanos to generate the object
private static int daysFromTimestamp(Timestamp timestamp) {
- return DateTimeUtil.daysFromInstant(timestamp.toInstant());
+ return
DateTimeUtil.daysFromDate(timestamp.toLocalDateTime().toLocalDate());
}
+ // We have to use the LocalDateTime to get the micros. See the comment above.
private static long microsFromTimestamp(Timestamp timestamp) {
- return DateTimeUtil.microsFromInstant(timestamp.toInstant());
+ return DateTimeUtil.microsFromTimestamp(timestamp.toLocalDateTime());
Review comment:
Even more surprised to see that, since I run my tests in CET and they
are running without problem. What timezone are you using? Are you using stock
Hive?
Thanks,
Peter
----------------------------------------------------------------
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]