amogh-jahagirdar commented on code in PR #11775:
URL: https://github.com/apache/iceberg/pull/11775#discussion_r1887748229


##########
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:
   FWIW I still think this is correct but it's worth getting other's 
perspective on this since we are changing one of the assumptions of how value 
is interpreted when the type to convert to is nanoseconds.
   
   CC @nastra @epgif @jacobmarble @rdblue thoughts? 



##########
api/src/test/java/org/apache/iceberg/types/TestConversions.java:
##########
@@ -111,9 +111,9 @@ public void testByteBufferConversions() {
     assertConversion(
         400000000L, TimestampNanoType.withZone(), new byte[] {0, -124, -41, 
23, 0, 0, 0, 0});
     
assertThat(Literal.of(400000L).to(TimestampNanoType.withoutZone()).toByteBuffer().array())
-        .isEqualTo(new byte[] {0, -124, -41, 23, 0, 0, 0, 0});
+        .isEqualTo(new byte[] {-128, 26, 6, 0, 0, 0, 0, 0});
     
assertThat(Literal.of(400000L).to(TimestampNanoType.withZone()).toByteBuffer().array())

Review Comment:
   Ah I see the comment on line 107/108. Could we update the `assertConversion` 
to instead test against 400000L and then remove the comment. At this point we 
are no longer having to pass in different values since we 
Literal.of(someLong).to(TimestampNanos) will always interpret someLong as 
nanoseconds.



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