rdblue commented on a change in pull request #1326:
URL: https://github.com/apache/iceberg/pull/1326#discussion_r474804819



##########
File path: 
mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergFilterFactory.java
##########
@@ -140,18 +137,34 @@ private static Object leafToLiteral(PredicateLeaf leaf) {
       case STRING:
         return leaf.getLiteralList();
       case DATE:
-        return leaf.getLiteralList().stream().map(value -> ((Date) 
value).toLocalDate().toEpochDay())
+        return leaf.getLiteralList().stream().map(value -> dateToString((Date) 
value))
                 .collect(Collectors.toList());
       case DECIMAL:
         return leaf.getLiteralList().stream()
-                .map(value -> BigDecimal.valueOf(((HiveDecimalWritable) 
value).doubleValue()))
+                .map(value -> hiveDecimalToBigDecimal((HiveDecimalWritable) 
value))
                 .collect(Collectors.toList());
       case TIMESTAMP:
         return leaf.getLiteralList().stream()
-                .map(value -> ((Timestamp) value).toInstant().getEpochSecond() 
* MICROS_PER_SECOND +
-                        ((Timestamp) value).getNanos() / 
NANOS_PER_MICROSEC).collect(Collectors.toList());
+                .map(value -> timestampToTimestampString((Timestamp) value))
+                .collect(Collectors.toList());
       default:
-        throw new IllegalStateException("Unknown type: " + leaf.getType());
+        throw new UnsupportedOperationException("Unknown type: " + 
leaf.getType());
     }
   }
+
+  private static String timestampToDateString(Timestamp timestamp) {
+    return timestamp.toLocalDateTime().toLocalDate().toString();
+  }
+
+  private static String dateToString(Date date) {
+    return date.toLocalDate().toString();
+  }
+
+  private static BigDecimal hiveDecimalToBigDecimal(HiveDecimalWritable 
hiveDecimalWritable) {
+    return new 
BigDecimal(hiveDecimalWritable.toString()).setScale(hiveDecimalWritable.scale());

Review comment:
       I don't think we want to convert to String here, either. Can you use the 
same logic from ORC?




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to