pwoody commented on a change in pull request #8167:
URL: https://github.com/apache/arrow/pull/8167#discussion_r488195930



##########
File path: 
java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/consumer/DateConsumer.java
##########
@@ -85,9 +71,10 @@ public void consume(ResultSet resultSet) throws SQLException 
{
       Date date = calendar == null ? resultSet.getDate(columnIndexInResultSet) 
:
           resultSet.getDate(columnIndexInResultSet, calendar);
       if (!resultSet.wasNull()) {
-        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;

Review comment:
       I've made it toIntExact to be more explicit about what we are going for 
@liyafan82 .
   
   LargeMemoryUtil#checkedCastToInt seems to be guarded by an unrelated 
property (ARROW_ENABLE_UNSAFE_MEMORY_ACCESS) and also just seems to be 
implemented incorrectly:
   `length <= Integer.MAX_VALUE || length >= Integer.MIN_VALUE` is always true? 
Think we want that to be an && (or we simply delegate to the toIntExact like 
above).




----------------------------------------------------------------
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]


Reply via email to