NGA-TRAN commented on a change in pull request #948:
URL: https://github.com/apache/arrow-datafusion/pull/948#discussion_r696870280
##########
File path: datafusion/src/physical_plan/sort_preserving_merge.rs
##########
@@ -1172,4 +1208,59 @@ mod tests {
assert_eq!(basic, partition);
}
+
+ #[tokio::test]
+ async fn test_merge_metrics() {
+ let a: ArrayRef = Arc::new(Int32Array::from(vec![1, 2]));
+ let b: ArrayRef = Arc::new(StringArray::from_iter(vec![Some("a"),
Some("c")]));
+ let b1 = RecordBatch::try_from_iter(vec![("a", a), ("b", b)]).unwrap();
+
+ let a: ArrayRef = Arc::new(Int32Array::from(vec![10, 20]));
+ let b: ArrayRef = Arc::new(StringArray::from_iter(vec![Some("b"),
Some("d")]));
+ let b2 = RecordBatch::try_from_iter(vec![("a", a), ("b", b)]).unwrap();
+
+ let schema = b1.schema();
+ let sort = vec![PhysicalSortExpr {
+ expr: col("b", &schema).unwrap(),
+ options: Default::default(),
+ }];
+ let exec = MemoryExec::try_new(&[vec![b1], vec![b2]], schema,
None).unwrap();
+ let merge = Arc::new(SortPreservingMergeExec::new(sort,
Arc::new(exec), 1024));
+
+ let collected = collect(merge.clone()).await.unwrap();
+ let expected = vec![
+ "+----+---+",
+ "| a | b |",
+ "+----+---+",
+ "| 1 | a |",
+ "| 10 | b |",
+ "| 2 | c |",
+ "| 20 | d |",
+ "+----+---+",
+ ];
+ assert_batches_eq!(expected, collected.as_slice());
+
+ // Now, validate metrics
+ let metrics = merge.metrics().unwrap();
+
+ assert!(metrics.output_rows().unwrap() > 0);
Review comment:
I think we can verify the exact output_rows here, right?
--
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]