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 74b90d9a5
As I fixed this, I noticed that exceptions thrown for "unsupported timestamp
unit" were inconsistent, so I cleaned that up in e0f6d3b1f
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]