Skip to content

Commit c7668ba

Browse files
committed
Fix custom metric display (apache#20643)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes part of datafusion-contrib/datafusion-distributed#361. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> The custom metrics display is unnecessarily prepending the name of the metric during the display: ``` network_latency_min_2=name:network_latency_min 274.88µs ``` When it should just be: ``` network_latency_min_2=274.88µs ``` ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Fix to the display ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> yes, by a new test ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> (cherry picked from commit 657887d)
1 parent a4a3923 commit c7668ba

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • datafusion/physical-expr-common/src/metrics

datafusion/physical-expr-common/src/metrics/value.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,8 +1050,8 @@ impl Display for MetricValue {
10501050
write!(f, "{pruning_metrics}")
10511051
}
10521052
Self::Ratio { ratio_metrics, .. } => write!(f, "{ratio_metrics}"),
1053-
Self::Custom { name, value } => {
1054-
write!(f, "name:{name} {value}")
1053+
Self::Custom { value, .. } => {
1054+
write!(f, "{value}")
10551055
}
10561056
}
10571057
}
@@ -1146,6 +1146,12 @@ mod tests {
11461146
}
11471147
}
11481148

1149+
#[test]
1150+
fn test_display_custom_metric() {
1151+
let custom_val = new_custom_counter("hi", 11);
1152+
assert_eq!(custom_val.to_string(), "count: 11");
1153+
}
1154+
11491155
#[test]
11501156
fn test_display_output_rows() {
11511157
let count = Count::new();

0 commit comments

Comments
 (0)