gerashegalov commented on code in PR #18775:
URL: https://github.com/apache/iceberg/pull/18775#discussion_r4774046864


##########
spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/BatchDataReader.java:
##########
@@ -91,9 +93,15 @@ class BatchDataReader extends BaseBatchReader<FileScanTask>
 
   @Override
   public CustomTaskMetric[] currentMetricsValues() {
-    return new CustomTaskMetric[] {
-      new TaskNumSplits(numSplits), new TaskNumDeletes(counter().get())
-    };
+    return inheritedMetrics.addTo(
+        new TaskNumSplits(numSplits),
+        new TaskNumDeletes(counter().get()),
+        new TaskScanDuration(scanDurationNanos()));

Review Comment:
   No test checks inherited scanDuration here or in `RowDataReader`, and these 
are the readers that scans create (`SparkColumnarReaderFactory`, 
`SparkRowReaderFactory`).
   - The inherited check in `TestMergingSortedRowDataReader` drives 
`MergingSortedRowDataReader`, which nothing calls outside tests yet.
   - `metricsWhenTaskReadsSeveralPartitions` asserts only `numSplits` and 
`numDeletes`.
   
   I tried moving `new TaskScanDuration(scanDurationNanos())` out of `addTo` 
here and in `RowDataReader`. `TestSparkReadMetrics`, 
`TestMergingSortedRowDataReader` and `TestScanDuration` all still pass. A 
conflict resolution against #19089 could easily end up like that, since it 
changes these same lines.
   
   #19022 already has the tests for 3.5: 
[`batchReaderScanDurationIncludesPreviousReader` and 
`rowReaderScanDurationIncludesPreviousReader`](https://github.com/apache/iceberg/pull/19022/files#diff-ed600e07fef45ec1588b998d2176e5cbae74d2b2726c7b5ceb38ee73d92437aaR628).
 They apply cleanly to 4.0, pass here, and fail with the change above. Could 
you port them?
   
   Optionally, assert while draining that `scanDurationNanos()` never 
decreases. That would also catch `+=` turning into `=` in `BaseReader.next()`, 
which no test covers today (on 4.1 and 4.2 either).



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