xudong963 commented on code in PR #17061: URL: https://github.com/apache/datafusion/pull/17061#discussion_r2262552931
########## datafusion/core/tests/physical_optimizer/partition_statistics.rs: ########## @@ -758,4 +760,47 @@ mod test { Ok(()) } + + #[tokio::test] + async fn test_statistic_by_partition_of_repartition() -> Result<()> { + let scan = create_scan_exec_with_statistics(None, Some(1)).await; + + let repartition = Arc::new(RepartitionExec::try_new( + scan.clone(), + Partitioning::RoundRobinBatch(2), + )?); + + let statistics = (0..repartition.partitioning().partition_count()) + .map(|idx| repartition.partition_statistics(Some(idx))) + .collect::<Result<Vec<_>>>()?; + assert_eq!(statistics.len(), 2); + + let expected_stats = Statistics { + num_rows: Precision::Inexact(2), + total_byte_size: Precision::Inexact(110), + column_statistics: vec![ + ColumnStatistics { + null_count: Precision::Absent, + max_value: Precision::Exact(ScalarValue::Int32(Some(4))), + min_value: Precision::Exact(ScalarValue::Int32(Some(1))), + sum_value: Precision::Absent, + distinct_count: Precision::Absent, + }, + ColumnStatistics { + null_count: Precision::Absent, + max_value: Precision::Absent, + min_value: Precision::Absent, + sum_value: Precision::Absent, + distinct_count: Precision::Absent, + }, + ], + }; + + // All partitions should have the same statistics + for stat in statistics.iter() { + assert_eq!(stat, &expected_stats); + } + + Ok(()) Review Comment: I also suggest testing with real execution, like this: https://github.com/apache/datafusion/blob/main/datafusion/core/tests/physical_optimizer/partition_statistics.rs#L722-L729 -- 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-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org