ebyhr commented on code in PR #11775:
URL: https://github.com/apache/iceberg/pull/11775#discussion_r2074715304


##########
api/src/main/java/org/apache/iceberg/expressions/Literals.java:
##########
@@ -300,8 +300,7 @@ public <T> Literal<T> to(Type type) {
         case TIMESTAMP:
           return (Literal<T>) new TimestampLiteral(value());
         case TIMESTAMP_NANO:
-          // assume micros and convert to nanos to match the behavior in the 
timestamp case above
-          return new TimestampLiteral(value()).to(type);
+          return (Literal<T>) new TimestampNanoLiteral(value());

Review Comment:
   @Fokko Could you re-open this PR? I tried string literal approach. It works 
on data columns, but results in exception on partition columns. 
   
   For instance, if we pass `ref(name="part_col") in 
("2022-07-26T12:13:14.123456789")` to  `Scan#filter` method, the `Projections` 
line converts the expression to `ref(name="part_col") == 1658837594123456789` 
and then results in the following stacktrace.
   
   Factory methods won't help in this case in my understanding. 
   
   
https://github.com/apache/iceberg/blob/84741867b9220f47b8e9a83edfb1be14d40cbefc/core/src/main/java/org/apache/iceberg/ManifestGroup.java#L253-L255
   
   ```
   java.lang.ArithmeticException: long overflow
        at java.base/java.lang.Math.multiplyExact(Math.java:1033)
        at 
org.apache.iceberg.util.DateTimeUtil.microsToNanos(DateTimeUtil.java:101)
        at 
org.apache.iceberg.expressions.Literals$TimestampLiteral.to(Literals.java:445)
        at 
org.apache.iceberg.expressions.Literals$LongLiteral.to(Literals.java:304)
        at 
org.apache.iceberg.expressions.UnboundPredicate.bindLiteralOperation(UnboundPredicate.java:171)
        at 
org.apache.iceberg.expressions.UnboundPredicate.bind(UnboundPredicate.java:122)
        at 
org.apache.iceberg.expressions.Binder$BindVisitor.predicate(Binder.java:159)
        at 
org.apache.iceberg.expressions.Binder$BindVisitor.predicate(Binder.java:118)
        at 
org.apache.iceberg.expressions.ExpressionVisitors.visit(ExpressionVisitors.java:347)
        at org.apache.iceberg.expressions.Binder.bind(Binder.java:60)
        at 
org.apache.iceberg.expressions.ManifestEvaluator.<init>(ManifestEvaluator.java:67)
        at 
org.apache.iceberg.expressions.ManifestEvaluator.forPartitionFilter(ManifestEvaluator.java:63)
        at 
org.apache.iceberg.ManifestGroup.lambda$entries$8(ManifestGroup.java:252)
        at 
com.github.benmanes.caffeine.cache.LocalLoadingCache.lambda$newMappingFunction$3(LocalLoadingCache.java:185)
        at 
com.github.benmanes.caffeine.cache.UnboundedLocalCache.lambda$computeIfAbsent$2(UnboundedLocalCache.java:297)
        at 
java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1713)
        at 
com.github.benmanes.caffeine.cache.UnboundedLocalCache.computeIfAbsent(UnboundedLocalCache.java:293)
        at 
com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
        at 
com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:60)
        at 
org.apache.iceberg.ManifestGroup.lambda$entries$9(ManifestGroup.java:275)
        at 
org.apache.iceberg.io.CloseableIterable$5.shouldKeep(CloseableIterable.java:156)
        at org.apache.iceberg.io.FilterIterator.advance(FilterIterator.java:66)
        at org.apache.iceberg.io.FilterIterator.hasNext(FilterIterator.java:49)
        at org.apache.iceberg.io.FilterIterator.advance(FilterIterator.java:64)
        at org.apache.iceberg.io.FilterIterator.hasNext(FilterIterator.java:49)
        at 
org.apache.iceberg.io.CloseableIterator$3.hasNext(CloseableIterator.java:91)
        at 
org.apache.iceberg.relocated.com.google.common.collect.TransformedIterator.hasNext(TransformedIterator.java:45)
        at 
org.apache.iceberg.io.CloseableIterable$ConcatCloseableIterable$ConcatCloseableIterator.hasNext(CloseableIterable.java:264)
   ```



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