rdblue commented on a change in pull request #1368:
URL: https://github.com/apache/iceberg/pull/1368#discussion_r477439181



##########
File path: 
api/src/main/java/org/apache/iceberg/transforms/TimestampTransform.java
##########
@@ -28,22 +28,47 @@
 import org.apache.iceberg.expressions.Expression;
 import org.apache.iceberg.expressions.Expressions;
 import org.apache.iceberg.expressions.UnboundPredicate;
+import org.apache.iceberg.relocated.com.google.common.base.Objects;
 import org.apache.iceberg.types.Type;
 import org.apache.iceberg.types.Types;
 
-enum Timestamps implements Transform<Long, Integer> {
-  YEAR(ChronoUnit.YEARS, "year"),
-  MONTH(ChronoUnit.MONTHS, "month"),
-  DAY(ChronoUnit.DAYS, "day"),
-  HOUR(ChronoUnit.HOURS, "hour");
+abstract class TimestampTransform implements Transform<Long, Integer> {
 
   private static final OffsetDateTime EPOCH = 
Instant.ofEpochSecond(0).atOffset(ZoneOffset.UTC);
-  private final ChronoUnit granularity;
-  private final String name;
 
-  Timestamps(ChronoUnit granularity, String name) {
+  private ChronoUnit granularity;
+  private String name;
+  private ZoneOffset zoneOffset;
+
+  @SuppressWarnings("unchecked")
+  static TimestampTransform get(Type type, String name) {
+    if (type.typeId() == Type.TypeID.TIMESTAMP) {
+      switch (name.toUpperCase()) {
+        case "YEAR":
+          return new TimestampTransform.TimestampYear(name.toLowerCase());
+        case "MONTH":
+          return new TimestampTransform.TimestampMonth(name.toLowerCase());
+        case "DAY":
+          return new TimestampTransform.TimestampDay(name.toLowerCase());
+        case "HOUR":
+          return new TimestampTransform.TimestampHour(name.toLowerCase());
+        default:
+          throw new UnsupportedOperationException("Unsupported timestamp 
method: " + name);
+      }
+    }
+    throw new UnsupportedOperationException(
+        "TimestampTransform cannot transform type: " + type);
+  }
+
+  private TimestampTransform(ChronoUnit granularity, String name) {
     this.granularity = granularity;
     this.name = name;
+    this.zoneOffset = ZoneOffset.UTC;
+  }
+
+  public TimestampTransform zoneOffset(ZoneOffset newZoneOffset) {
+    this.zoneOffset = newZoneOffset;

Review comment:
       Why is `zoneOffset` mutable?




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to