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



##########
File path: api/src/main/java/org/apache/iceberg/PartitionSpec.java
##########
@@ -380,58 +381,78 @@ public Builder identity(String sourceName) {
       return identity(sourceName, sourceName);
     }
 
-    public Builder year(String sourceName, String targetName) {
+    public Builder year(String sourceName, String targetName, String offsetId) 
{
       checkAndAddPartitionName(targetName);
       Types.NestedField sourceColumn = findSourceColumn(sourceName);
       PartitionField field = new PartitionField(
-          sourceColumn.fieldId(), nextFieldId(), targetName, 
Transforms.year(sourceColumn.type()));
+          sourceColumn.fieldId(), nextFieldId(), targetName,
+          Transforms.year(sourceColumn.type(), ZoneOffset.of(offsetId)));
       checkForRedundantPartitions(field);
       fields.add(field);
       return this;
     }
 
+    public Builder year(String sourceName, String targetName) {
+      return year(sourceName, targetName, "Z");
+    }
+
     public Builder year(String sourceName) {
       return year(sourceName, sourceName + "_year");
     }
 
-    public Builder month(String sourceName, String targetName) {
+    public Builder month(String sourceName, String targetName, String 
offsetId) {
       checkAndAddPartitionName(targetName);
       Types.NestedField sourceColumn = findSourceColumn(sourceName);
       PartitionField field = new PartitionField(
-          sourceColumn.fieldId(), nextFieldId(), targetName, 
Transforms.month(sourceColumn.type()));
+          sourceColumn.fieldId(), nextFieldId(), targetName,
+          Transforms.month(sourceColumn.type(), ZoneOffset.of(offsetId)));

Review comment:
       `ZoneOffset.of` supports a broader range of values than Iceberg (which 
wouldn't support `Z`, for example). I'm a bit concerned that using it here 
erases what the user passed in. What about keeping the string and making 
`ZoneOffset` internal to `TimestampTransform`?




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