You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/08/26 20:51:21 UTC

[GitHub] [arrow-datafusion] alamb commented on a change in pull request #948: Add baseline metrics to `SortPreservingMergeExec`

alamb commented on a change in pull request #948:
URL: https://github.com/apache/arrow-datafusion/pull/948#discussion_r696965707



##########
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:
       that is a good point. Will do




-- 
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-unsubscribe@arrow.apache.org

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