aokolnychyi commented on a change in pull request #2984:
URL: https://github.com/apache/iceberg/pull/2984#discussion_r690545444



##########
File path: core/src/main/java/org/apache/iceberg/MetadataColumns.java
##########
@@ -49,26 +54,40 @@ private MetadataColumns() {
   public static final String DELETE_FILE_ROW_DOC = "Deleted row values";
 
   private static final Map<String, NestedField> META_COLUMNS = ImmutableMap.of(
+      SPEC.name(), SPEC,
       FILE_PATH.name(), FILE_PATH,
       ROW_POSITION.name(), ROW_POSITION,
       IS_DELETED.name(), IS_DELETED);
 
-  private static final Set<Integer> META_IDS = 
META_COLUMNS.values().stream().map(NestedField::fieldId)
-      .collect(ImmutableSet.toImmutableSet());
+  private static final Set<Integer> META_IDS = ImmutableSet.of(
+      PARTITION_COLUMN_ID,
+      SPEC.fieldId(),
+      FILE_PATH.fieldId(),
+      ROW_POSITION.fieldId(),
+      IS_DELETED.fieldId()
+  );
 
   public static Set<Integer> metadataFieldIds() {
     return META_IDS;
   }
 
-  public static NestedField get(String name) {
-    return META_COLUMNS.get(name);
+  public static NestedField metadataColumn(Table table, String name) {
+    if (name.equals(PARTITION_COLUMN_NAME)) {
+      return Types.NestedField.optional(
+          PARTITION_COLUMN_ID,
+          PARTITION_COLUMN_NAME,
+          Partitioning.partitionType(table),
+          PARTITION_COLUMN_DOC);
+    } else {
+      return META_COLUMNS.get(name);
+    }
   }
 
   public static boolean isMetadataColumn(String name) {
-    return META_COLUMNS.containsKey(name);
+    return name.equals(PARTITION_COLUMN_NAME) || 
META_COLUMNS.containsKey(name);

Review comment:
       I did that first but `META_COLUMNS` is an immutable map that does not 
allow null keys. I am reluctant to switch to a mutable map so I added this 
condition here. I hope we will be able to use `metadataColumn(table, name)` in 
other places so this workaround will be only part of `MetadataColumns`.
   
   It looks ugly, though, I agree.
   




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

Reply via email to