amogh-jahagirdar commented on code in PR #11775: URL: https://github.com/apache/iceberg/pull/11775#discussion_r1887202656
########## 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: This change seems correct to me, the previous behavior for this was to assume the value was in microseconds and then pass that through to TimestampLiteral but that can overflow and does not actually represent a nanosecond timestamp! ########## api/src/test/java/org/apache/iceberg/expressions/TestTimestampLiteralConversions.java: ########## @@ -107,6 +108,28 @@ public void testTimestampMicrosToDateConversion() { assertThat(dateOrdinal).isEqualTo(-1); } + @Test + public void testTimestampNanoWithLongLiteral() { Review Comment: could we also add a case for `withZone`? ########## 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: I'm a bit confused how the original assertion was passing? Shouldn't have this always been equivalent to `{-128, 26, 6, 0, 0, 0, 0, 0}`? -- 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