rdblue commented on code in PR #9008: URL: https://github.com/apache/iceberg/pull/9008#discussion_r1421812479
########## api/src/main/java/org/apache/iceberg/expressions/Literals.java: ########## @@ -426,16 +428,40 @@ protected Type.TypeID typeId() { } static class TimestampLiteral extends ComparableLiteral<Long> { - TimestampLiteral(Long value) { + private final ChronoUnit unit; + + TimestampLiteral(ChronoUnit unit, Long value) { super(value); + this.unit = unit; } @Override @SuppressWarnings("unchecked") public <T> Literal<T> to(Type type) { switch (type.typeId()) { case TIMESTAMP: - return (Literal<T>) this; + ChronoUnit toUnit = ((TimestampType) type).unit(); + switch (unit) { + case MICROS: + switch (toUnit) { + case MICROS: + return (Literal<T>) this; + case NANOS: + return (Literal<T>) + new TimestampLiteral(unit, DateTimeUtil.microsToNanos(value())); + } + break; + case NANOS: + switch (toUnit) { + case MICROS: + return (Literal<T>) + new TimestampLiteral(unit, DateTimeUtil.nanosToMicros(value())); + case NANOS: + return (Literal<T>) this; + } + break; + } + break; Review Comment: Conversion to date needs to be updated as well. -- 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