@@ -63,6 +63,9 @@ pub struct BaselineMetrics {
6363 /// multiple times.
6464 /// Issue: <https://github.com/apache/datafusion/issues/16841>
6565 output_bytes : Count ,
66+
67+ /// output batches: the total batch count
68+ output_batches : Count ,
6669 // Remember to update `docs/source/user-guide/metrics.md` when updating comments
6770 // or adding new metrics
6871}
@@ -86,6 +89,9 @@ impl BaselineMetrics {
8689 output_bytes : MetricBuilder :: new ( metrics)
8790 . with_type ( super :: MetricType :: SUMMARY )
8891 . output_bytes ( partition) ,
92+ output_batches : MetricBuilder :: new ( metrics)
93+ . with_type ( super :: MetricType :: SUMMARY )
94+ . output_batches ( partition) ,
8995 }
9096 }
9197
@@ -100,6 +106,7 @@ impl BaselineMetrics {
100106 elapsed_compute : self . elapsed_compute . clone ( ) ,
101107 output_rows : Default :: default ( ) ,
102108 output_bytes : Default :: default ( ) ,
109+ output_batches : Default :: default ( ) ,
103110 }
104111 }
105112
@@ -113,6 +120,11 @@ impl BaselineMetrics {
113120 & self . output_rows
114121 }
115122
123+ /// return the metric for the total number of output batches produced
124+ pub fn output_batches ( & self ) -> & Count {
125+ & self . output_batches
126+ }
127+
116128 /// Records the fact that this operator's execution is complete
117129 /// (recording the `end_time` metric).
118130 ///
@@ -229,6 +241,7 @@ impl RecordOutput for RecordBatch {
229241 bm. record_output ( self . num_rows ( ) ) ;
230242 let n_bytes = get_record_batch_memory_size ( & self ) ;
231243 bm. output_bytes . add ( n_bytes) ;
244+ bm. output_batches . add ( 1 ) ;
232245 self
233246 }
234247}
@@ -238,6 +251,7 @@ impl RecordOutput for &RecordBatch {
238251 bm. record_output ( self . num_rows ( ) ) ;
239252 let n_bytes = get_record_batch_memory_size ( self ) ;
240253 bm. output_bytes . add ( n_bytes) ;
254+ bm. output_batches . add ( 1 ) ;
241255 self
242256 }
243257}
0 commit comments