rdblue commented on code in PR #16958:
URL: https://github.com/apache/iceberg/pull/16958#discussion_r3583445578


##########
core/src/main/java/org/apache/iceberg/TrackedFile.java:
##########
@@ -95,26 +96,40 @@ interface TrackedFile {
           Types.ListType.ofRequired(136, Types.IntegerType.get()),
           "Field ids used to determine row equality in equality delete files");
 
+  /**
+   * Returns the schema for the given partition and content stats types.
+   *
+   * <p>The partition and content stats fields are omitted when their types 
have no fields.
+   */
   static Types.StructType schemaWithContentStats(
       Types.StructType partitionType, Types.StructType contentStatsType) {
-    return Types.StructType.of(
-        TRACKING,
-        CONTENT_TYPE,
-        FORMAT_VERSION,
-        LOCATION,
-        FILE_FORMAT,
-        RECORD_COUNT,
-        FILE_SIZE_IN_BYTES,
-        SPEC_ID,
-        Types.NestedField.optional(PARTITION_ID, PARTITION_NAME, 
partitionType, PARTITION_DOC),
-        Types.NestedField.optional(
-            CONTENT_STATS_ID, CONTENT_STATS_NAME, contentStatsType, 
CONTENT_STATS_DOC),
-        SORT_ORDER_ID,
-        DELETION_VECTOR,
-        MANIFEST_INFO,
-        KEY_METADATA,
-        SPLIT_OFFSETS,
-        EQUALITY_IDS);
+    List<Types.NestedField> fields = Lists.newArrayList();
+    fields.add(TRACKING);
+    fields.add(CONTENT_TYPE);
+    fields.add(FORMAT_VERSION);
+    fields.add(LOCATION);
+    fields.add(FILE_FORMAT);
+    fields.add(RECORD_COUNT);
+    fields.add(FILE_SIZE_IN_BYTES);
+    fields.add(SPEC_ID);
+    if (!partitionType.fields().isEmpty()) {
+      fields.add(
+          Types.NestedField.optional(PARTITION_ID, PARTITION_NAME, 
partitionType, PARTITION_DOC));

Review Comment:
   Could we use `UnknownType.get` instead? That way we always have a field, but 
it isn't written if the partition type is empty.



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

Reply via email to