github-actions[bot] commented on code in PR #65782:
URL: https://github.com/apache/doris/pull/65782#discussion_r3609284218


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/helper/IcebergWriterHelper.java:
##########
@@ -178,8 +185,25 @@ private static Metrics buildDataFileMetrics(Table table, 
FileFormat fileFormat,
             }
         }
 
-        return new Metrics(commitData.getRowCount(), columnSizes, valueCounts,
-                nullValueCounts, null, lowerBounds, upperBounds);
+        // Physical file stats may contain every column, but manifest metrics 
must honor the table's metadata policy.
+        return new Metrics(commitData.getRowCount(),
+                filterDisabledMetrics(columnSizes, schema, metricsConfig),
+                filterDisabledMetrics(valueCounts, schema, metricsConfig),
+                filterDisabledMetrics(nullValueCounts, schema, metricsConfig),
+                null,
+                filterDisabledMetrics(lowerBounds, schema, metricsConfig),
+                filterDisabledMetrics(upperBounds, schema, metricsConfig));
+    }
+
+    private static <T> Map<Integer, T> filterDisabledMetrics(
+            Map<Integer, T> metrics, Schema schema, MetricsConfig 
metricsConfig) {
+        Map<Integer, T> filteredMetrics = new HashMap<>();
+        metrics.forEach((fieldId, value) -> {
+            if (MetricsUtil.metricsMode(schema, metricsConfig, fieldId) != 
MetricsModes.None.get()) {

Review Comment:
   [P1] Apply the effective mode to each metric family
   
   Every non-`None` mode passes through the same raw maps here. With 
`write.metadata.metrics.default=counts`, the BE-provided lower/upper bounds are 
still written even though Iceberg counts mode must omit them; with the normal 
`truncate(16)` default (and explicit or sort-promoted truncate modes), long 
string/binary bounds are copied in full instead of using Iceberg's safe 
lower/upper truncation. The BE producers emit complete footer extrema and 
`DataFiles.Builder.withMetrics` does not reapply `MetricsConfig`, so these full 
values reach manifests. Please make bound handling mode-aware—drop bounds for 
`counts` and decode/truncate/re-encode string/binary bounds for 
`truncate(N)`—and add counts/truncate tests.



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