liyafan82 commented on a change in pull request #8167:
URL: https://github.com/apache/arrow/pull/8167#discussion_r488340043
##########
File path:
java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/consumer/DateConsumer.java
##########
@@ -123,9 +105,10 @@ public NonNullableDateConsumer(DateDayVector vector, int
index, Calendar calenda
public void consume(ResultSet resultSet) throws SQLException {
Date date = calendar == null ? resultSet.getDate(columnIndexInResultSet)
:
resultSet.getDate(columnIndexInResultSet, calendar);
- int day = (int) TimeUnit.MILLISECONDS.toDays(date.getTime());
- if (day < 0 || day > MAX_DAY) {
- throw new IllegalArgumentException("Day overflow: " + day);
+ long dayLong = TimeUnit.MILLISECONDS.toDays(date.getTime());
+ int day = (int) dayLong;
+ if (day != dayLong) {
+ throw new IllegalArgumentException("Day overflow: " + dayLong);
Review comment:
Maybe we should also use Math.toIntExact 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]