epgif commented on code in PR #9008:
URL: https://github.com/apache/iceberg/pull/9008#discussion_r1539852462


##########
api/src/main/java/org/apache/iceberg/expressions/ExpressionUtil.java:
##########
@@ -595,11 +613,17 @@ private static String sanitizeString(CharSequence value, 
long now, int today) {
         Literal<Integer> date = Literal.of(value).to(Types.DateType.get());
         return sanitizeDate(date.value(), today);
       } else if (TIMESTAMP.matcher(value).matches()) {
-        Literal<Long> ts = 
Literal.of(value).to(Types.TimestampType.withoutZone());
-        return sanitizeTimestamp(ts.value(), now);
+        Literal<Long> ts = 
Literal.of(value).to(Types.TimestampType.microsWithoutZone());
+        return sanitizeTimestamp(Types.TimestampType.Unit.MICROS, ts.value(), 
now);
+      } else if (TIMESTAMPNS.matcher(value).matches()) {
+        Literal<Long> ts = 
Literal.of(value).to(Types.TimestampType.nanosWithoutZone());
+        return sanitizeTimestamp(Types.TimestampType.Unit.NANOS, ts.value(), 
now);
       } else if (TIMESTAMPTZ.matcher(value).matches()) {
-        Literal<Long> ts = 
Literal.of(value).to(Types.TimestampType.withZone());
-        return sanitizeTimestamp(ts.value(), now);
+        Literal<Long> ts = 
Literal.of(value).to(Types.TimestampType.microsWithZone());
+        return sanitizeTimestamp(Types.TimestampType.Unit.MICROS, ts.value(), 
now);
+      } else if (TIMESTAMPTZNS.matcher(value).matches()) {
+        Literal<Long> ts = 
Literal.of(value).to(Types.TimestampType.nanosWithZone());
+        return sanitizeTimestamp(Types.TimestampType.Unit.NANOS, ts.value(), 
now);

Review Comment:
   I think the new version invalidates these comments, but just to be clear: we 
are not discarding the nanosecond component, and this is tested.



##########
api/src/main/java/org/apache/iceberg/expressions/Literals.java:
##########
@@ -501,19 +538,17 @@ public <T> Literal<T> to(Type type) {
           return (Literal<T>) new TimeLiteral(timeMicros);
 
         case TIMESTAMP:
-          if (((Types.TimestampType) type).shouldAdjustToUTC()) {
-            long timestampMicros =
-                ChronoUnit.MICROS.between(
-                    EPOCH, OffsetDateTime.parse(value(), 
DateTimeFormatter.ISO_DATE_TIME));
-            return (Literal<T>) new TimestampLiteral(timestampMicros);
+          final TimestampType tsType = (TimestampType) type;
+          final String value = value().toString();
+          final java.time.temporal.Temporal valueAsTemporal;

Review Comment:
   Done.



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

Reply via email to