alamb commented on code in PR #16195:
URL: https://github.com/apache/datafusion/pull/16195#discussion_r2126288404


##########
datafusion/physical-plan/src/metrics/value.rs:
##########
@@ -443,6 +528,9 @@ impl MetricValue {
                 .and_then(|ts| ts.timestamp_nanos_opt())
                 .map(|nanos| nanos as usize)
                 .unwrap_or(0),
+            Self::Custom { name, value } => {
+                value.as_usize().unwrap_or_else(|| 
panic!("MetricValue::as_usize isn't supported for custom metric values. 
({name}: {value:?})"))

Review Comment:
   I agree the panic should be removed good as it leaves a tricky to use 
correctly API: if users don't implement `CustomMetric::as_usize` then their 
query may panic. 
   
   One way to avoid the panic would be to cange the signature of  `as_usize` to 
return `usize` rather than `Option<usize>` and provide a default value -- maybe 
`0`
   
   In addition to returning `usize` we could also avoid  providing a custom 
implementation of `as_usize`and force the implementers to decide explicitly



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to