comphead commented on code in PR #4062:
URL: https://github.com/apache/datafusion-comet/pull/4062#discussion_r3443971910


##########
native/core/src/execution/metrics/utils.rs:
##########
@@ -71,14 +71,19 @@ pub(crate) fn to_native_metric_node(
         children: Vec::with_capacity(children.len()),
     };
 
-    if let Some(metrics) = node_metrics {
-        for m in metrics.iter() {
-            let value = m.value();
-            native_metric_node
-                .metrics
-                .insert(value.name().to_string(), value.as_usize() as i64);
-        }
-    }
+    // Aggregate metrics by name using DataFusion's aggregate_by_name(), which
+    // correctly handles duplicate metric names (e.g. BaselineMetrics 
registered
+    // by both FileStream and ParquetMorselizer on the same 
ExecutionPlanMetricsSet).
+    // The additional_native_plans branch below already does this.
+    node_metrics
+        .unwrap_or_default()
+        .aggregate_by_name()
+        .iter()
+        .map(|m| m.value())
+        .map(|m| (m.name(), m.as_usize() as i64))
+        .for_each(|(name, value)| {
+            native_metric_node.metrics.insert(name.to_string(), value);
+        });

Review Comment:
   we prob can simplify this to iterate once



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