petern48 commented on code in PR #18577:
URL: https://github.com/apache/datafusion/pull/18577#discussion_r2515663472


##########
datafusion/physical-plan/src/metrics/builder.rs:
##########
@@ -283,7 +275,17 @@ impl<'a> MetricBuilder<'a> {
         name: impl Into<Cow<'static, str>>,
         partition: usize,
     ) -> RatioMetrics {
-        let ratio_metrics = RatioMetrics::new();
+        self.ratio_metrics_with_strategy(name, partition, 
RatioMergeStrategy::default())
+    }
+
+    /// Consumes self and creates a new [`RatioMetrics`] with a specific merge 
strategy
+    pub fn ratio_metrics_with_strategy(
+        self,
+        name: impl Into<Cow<'static, str>>,
+        partition: usize,
+        merge_strategy: RatioMergeStrategy,
+    ) -> RatioMetrics {
+        let ratio_metrics = 
RatioMetrics::new().with_merge_strategy(merge_strategy);
         self.with_partition(partition).build(MetricValue::Ratio {
             name: name.into(),
             ratio_metrics: ratio_metrics.clone(),

Review Comment:
   Originally, I tried `builder.ratio_metrics().with_merge_strategy()` in 
metrics.rs,
   
   but found the merge strategy wasn't working since the 
`ratio_metrics.clone()` call here was registering the ratio_metrics before I 
added the merge strategy to it. Hence the need for this new 
`ratio_metrics_with_strategy()`



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