jacobmarble commented on code in PR #8971: URL: https://github.com/apache/iceberg/pull/8971#discussion_r1382167692
########## api/src/main/java/org/apache/iceberg/transforms/Transforms.java: ########## @@ -129,10 +131,14 @@ public static <T> Transform<T, Integer> year(Type type) { case DATE: return (Transform<T, Integer>) Dates.YEAR; case TIMESTAMP: - return (Transform<T, Integer>) Timestamps.YEAR; - default: - throw new IllegalArgumentException("Cannot partition type " + type + " by year"); + switch (((TimestampType) type).unit()) { + case MICROS: + return (Transform<T, Integer>) Timestamps.YEAR_FROM_MICROS; + case NANOS: + return (Transform<T, Integer>) Timestamps.YEAR_FROM_NANOS; + } } + throw new IllegalArgumentException("Cannot partition type " + type + " by year"); Review Comment: I agree. Fixed in 7b6e973f4ac0cb2ebd1a595eca0aad8ec2c1760f As I fixed this, I noticed that exceptions thrown for "unsupported timestamp unit" were inconsistent, so I cleaned that up in c52c3d9e96136eb574e4b1547e4c2afd07814ead -- 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