@@ -40,10 +40,12 @@ mod test {
40
40
} ;
41
41
use datafusion_physical_plan:: coalesce_batches:: CoalesceBatchesExec ;
42
42
use datafusion_physical_plan:: coalesce_partitions:: CoalescePartitionsExec ;
43
+ use datafusion_physical_plan:: common:: compute_record_batch_statistics;
43
44
use datafusion_physical_plan:: empty:: EmptyExec ;
44
45
use datafusion_physical_plan:: filter:: FilterExec ;
45
46
use datafusion_physical_plan:: joins:: CrossJoinExec ;
46
47
use datafusion_physical_plan:: limit:: { GlobalLimitExec , LocalLimitExec } ;
48
+ use datafusion_physical_plan:: placeholder_row:: PlaceholderRowExec ;
47
49
use datafusion_physical_plan:: projection:: ProjectionExec ;
48
50
use datafusion_physical_plan:: sorts:: sort:: SortExec ;
49
51
use datafusion_physical_plan:: union:: UnionExec ;
@@ -728,4 +730,32 @@ mod test {
728
730
729
731
Ok ( ( ) )
730
732
}
733
+
734
+ #[ tokio:: test]
735
+ async fn test_statistic_by_partition_of_placeholder_rows ( ) -> Result < ( ) > {
736
+ let schema =
737
+ Arc :: new ( Schema :: new ( vec ! [ Field :: new( "id" , DataType :: Int32 , false ) ] ) ) ;
738
+ let plan = Arc :: new ( PlaceholderRowExec :: new ( schema) . with_partitions ( 2 ) )
739
+ as Arc < dyn ExecutionPlan > ;
740
+ let schema = plan. schema ( ) ;
741
+
742
+ let ctx = TaskContext :: default ( ) ;
743
+ let partitions = execute_stream_partitioned ( Arc :: clone ( & plan) , Arc :: new ( ctx) ) ?;
744
+
745
+ let mut all_batches = vec ! [ ] ;
746
+ for ( i, partition_stream) in partitions. into_iter ( ) . enumerate ( ) {
747
+ let batches: Vec < RecordBatch > = partition_stream. try_collect ( ) . await ?;
748
+ let actual = plan. partition_statistics ( Some ( i) ) ?;
749
+ let expected =
750
+ compute_record_batch_statistics ( & [ batches. clone ( ) ] , & schema, None ) ;
751
+ assert_eq ! ( actual, expected) ;
752
+ all_batches. push ( batches) ;
753
+ }
754
+
755
+ let actual = plan. partition_statistics ( None ) ?;
756
+ let expected = compute_record_batch_statistics ( & all_batches, & schema, None ) ;
757
+ assert_eq ! ( actual, expected) ;
758
+
759
+ Ok ( ( ) )
760
+ }
731
761
}
0 commit comments