()
| 766 | |
| 767 | #[tokio::test] |
| 768 | async fn aggregate() -> Result<()> { |
| 769 | // build plan using DataFrame API |
| 770 | // union so some of the distincts have a clearly distinct result |
| 771 | let df = test_table().await?.union(test_table().await?)?; |
| 772 | let group_expr = vec![col("c1")]; |
| 773 | let aggr_expr = vec![ |
| 774 | min(col("c4")).alias("min(c4)"), |
| 775 | max(col("c4")).alias("max(c4)"), |
| 776 | avg(col("c4")).alias("avg(c4)"), |
| 777 | avg_distinct(col("c4")).alias("avg_distinct(c4)"), |
| 778 | sum(col("c4")).alias("sum(c4)"), |
| 779 | sum_distinct(col("c4")).alias("sum_distinct(c4)"), |
| 780 | count(col("c4")).alias("count(c4)"), |
| 781 | count_distinct(col("c4")).alias("count_distinct(c4)"), |
| 782 | ]; |
| 783 | |
| 784 | let df: Vec<RecordBatch> = df.aggregate(group_expr, aggr_expr)?.collect().await?; |
| 785 | |
| 786 | assert_snapshot!( |
| 787 | batches_to_sort_string(&df), |
| 788 | @r" |
| 789 | +----+---------+---------+---------------------+---------------------+---------+------------------+-----------+--------------------+ |
| 790 | | c1 | min(c4) | max(c4) | avg(c4) | avg_distinct(c4) | sum(c4) | sum_distinct(c4) | count(c4) | count_distinct(c4) | |
| 791 | +----+---------+---------+---------------------+---------------------+---------+------------------+-----------+--------------------+ |
| 792 | | a | -28462 | 32064 | 306.04761904761904 | 306.04761904761904 | 12854 | 6427 | 42 | 21 | |
| 793 | | b | -28070 | 25286 | 7732.315789473684 | 7732.315789473684 | 293828 | 146914 | 38 | 19 | |
| 794 | | c | -30508 | 29106 | -1320.5238095238096 | -1320.5238095238096 | -55462 | -27731 | 42 | 21 | |
| 795 | | d | -24558 | 31106 | 10890.111111111111 | 10890.111111111111 | 392044 | 196022 | 36 | 18 | |
| 796 | | e | -31500 | 32514 | -4268.333333333333 | -4268.333333333333 | -179270 | -89635 | 42 | 21 | |
| 797 | +----+---------+---------+---------------------+---------------------+---------+------------------+-----------+--------------------+ |
| 798 | " |
| 799 | ); |
| 800 | |
| 801 | Ok(()) |
| 802 | } |
| 803 | |
| 804 | #[tokio::test] |
| 805 | async fn aggregate_assert_no_empty_batches() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…