timothyw553 commented on code in PR #19282:
URL: https://github.com/apache/iceberg/pull/19282#discussion_r4794730045


##########
core/src/main/java/org/apache/iceberg/BaseIncrementalAppendScan.java:
##########
@@ -85,7 +85,8 @@ private CloseableIterable<FileScanTask> 
appendFilesFromSnapshots(List<Snapshot>
             .schemasById(schemas())
             .specsById(table().specs())
             .ignoreDeleted()
-            .columnsToKeepStats(columnsToKeepStats());
+            .columnsToKeepStats(columnsToKeepStats())
+            .scanMetrics(scanMetrics());

Review Comment:
   neither this nor `BaseIncrementalChangelogScan` initializes 
`totalDataManifests`, so reports end up with scanned manifests > 0 and total = 
0. should we increment it before building `ManifestGroup` (same for 
`newDataManifests.size()` in changelog) and test `total == scanned + skipped` 
with a manifest-skipping filter?
   ```diff
   +    scanMetrics().totalDataManifests().increment((long) manifests.size());
        ManifestGroup manifestGroup =
   ```



##########
core/src/main/java/org/apache/iceberg/BaseIncrementalScan.java:
##########
@@ -123,7 +146,33 @@ public CloseableIterable<T> planFiles() {
               true /* from snapshot ID inclusive */));
     }
 
-    return doPlanFiles(fromSnapshotIdExclusive, toSnapshotIdInclusive);
+    List<Integer> projectedFieldIds = 
Lists.newArrayList(TypeUtil.getProjectedIds(schema()));
+    List<String> projectedFieldNames =
+        
projectedFieldIds.stream().map(schema()::findColumnName).collect(Collectors.toList());
+
+    Timer.Timed planningDuration = 
scanMetrics().totalPlanningDuration().start();
+
+    return CloseableIterable.whenComplete(
+        doPlanFiles(fromSnapshotIdExclusive, toSnapshotIdInclusive),
+        () -> {
+          planningDuration.stop();
+          Map<String, String> metadata = Maps.newHashMap(context().options());
+          metadata.putAll(EnvironmentContext.get());
+          ScanReport scanReport =
+              ImmutableScanReport.builder()
+                  .schemaId(schema().schemaId())
+                  .projectedFieldIds(projectedFieldIds)
+                  .projectedFieldNames(projectedFieldNames)
+                  .tableName(table().name())
+                  .snapshotId(toSnapshotIdInclusive)
+                  .filter(
+                      ExpressionUtil.sanitize(
+                          schema().asStruct(), filter(), 
context().caseSensitive()))
+                  
.scanMetrics(ScanMetricsResult.fromScanMetrics(scanMetrics()))
+                  .metadata(metadata)
+                  .build();
+          context().metricsReporter().report(scanReport);

Review Comment:
   to my understanding `BaseTable.newIncrementalChangelogScan()` initializes 
`BaseIncrementalChangelogScan` with `TableScanContext.empty()`, so changelog 
scans silently miss the table's configured reporter unless 
`.metricsReporter(...)` is called on the scan. should we forward `reporter` in 
`BaseTable` and add a test that only configures the table reporter?
   ```diff
   -    return new BaseIncrementalChangelogScan(this);
   +    return new BaseIncrementalChangelogScan(this).metricsReporter(reporter);
   ```



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