szehon-ho commented on code in PR #7539:
URL: https://github.com/apache/iceberg/pull/7539#discussion_r1192587961


##########
core/src/main/java/org/apache/iceberg/BaseEntriesTable.java:
##########
@@ -125,31 +130,120 @@ ManifestFile manifest() {
 
     @Override
     public CloseableIterable<StructLike> rows() {
-      // Project data-file fields
-      CloseableIterable<StructLike> prunedRows;
-      if (manifest.content() == ManifestContent.DATA) {
-        prunedRows =
+      Types.NestedField readableMetricsField = 
projection.findField(MetricsUtil.READABLE_METRICS);
+
+      if (readableMetricsField == null) {
+        CloseableIterable<StructLike> entryAsStruct =
             CloseableIterable.transform(
-                ManifestFiles.read(manifest, io).project(fileSchema).entries(),
-                file -> (GenericManifestEntry<DataFile>) file);
+                entries(fileProjection),
+                entry -> (GenericManifestEntry<? extends ContentFile<?>>) 
entry);
+
+        StructProjection structProjection = structProjection(projection);
+        return CloseableIterable.transform(entryAsStruct, 
structProjection::wrap);
       } else {
-        prunedRows =
-            CloseableIterable.transform(
-                ManifestFiles.readDeleteManifest(manifest, io, specsById)
-                    .project(fileSchema)
-                    .entries(),
-                file -> (GenericManifestEntry<DeleteFile>) file);
+        Schema requiredFileProjection = requiredFileProjection();
+        Schema actualProjection = removeReadableMetrics(readableMetricsField);
+        StructProjection structProjection = structProjection(actualProjection);
+
+        return CloseableIterable.transform(
+            entries(requiredFileProjection),
+            entry -> withReadableMetrics(structProjection, entry, 
readableMetricsField));
       }
+    }
+
+    /**
+     * Ensure that the underlying metrics used to create those columns are 
part of the file

Review Comment:
   Nit: looks like 'those columns' is unnecessarily ambiguous and we can maybe 
just do , to avoid repetition.  
   ```
   /**
    *  Ensure that the underlying metrics used to populate readable metrics 
column are part of the file projection.
    **/
    ```
    Its no big deal though if you don't  get to it, approved the pr and will 
merge if no further comment
    
    



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