@@ -636,6 +636,9 @@ pub struct ExecutionConfig {
636636 /// Should DataFusion repartition data using the join keys to execute joins in parallel
637637 /// using the provided `concurrency` level
638638 pub repartition_joins : bool ,
639+ /// Should DataFusion repartition data using the aggregate keys to execute aggregates in parallel
640+ /// using the provided `concurrency` level
641+ pub repartition_aggregations : bool ,
639642}
640643
641644impl ExecutionConfig {
@@ -663,6 +666,7 @@ impl ExecutionConfig {
663666 create_default_catalog_and_schema : true ,
664667 information_schema : false ,
665668 repartition_joins : true ,
669+ repartition_aggregations : true ,
666670 }
667671 }
668672
@@ -746,6 +750,11 @@ impl ExecutionConfig {
746750 self . repartition_joins = enabled;
747751 self
748752 }
753+ /// Enables or disables the use of repartitioning for aggregations to improve parallelism
754+ pub fn with_repartition_aggregations ( mut self , enabled : bool ) -> Self {
755+ self . repartition_aggregations = enabled;
756+ self
757+ }
749758}
750759
751760/// Holds per-execution properties and data (such as starting timestamps, etc).
@@ -1351,7 +1360,6 @@ mod tests {
13511360 #[ tokio:: test]
13521361 async fn aggregate_grouped ( ) -> Result < ( ) > {
13531362 let results = execute ( "SELECT c1, SUM(c2) FROM test GROUP BY c1" , 4 ) . await ?;
1354- assert_eq ! ( results. len( ) , 1 ) ;
13551363
13561364 let expected = vec ! [
13571365 "+----+---------+" ,
@@ -1371,7 +1379,6 @@ mod tests {
13711379 #[ tokio:: test]
13721380 async fn aggregate_grouped_avg ( ) -> Result < ( ) > {
13731381 let results = execute ( "SELECT c1, AVG(c2) FROM test GROUP BY c1" , 4 ) . await ?;
1374- assert_eq ! ( results. len( ) , 1 ) ;
13751382
13761383 let expected = vec ! [
13771384 "+----+---------+" ,
@@ -1392,7 +1399,6 @@ mod tests {
13921399 async fn boolean_literal ( ) -> Result < ( ) > {
13931400 let results =
13941401 execute ( "SELECT c1, c3 FROM test WHERE c1 > 2 AND c3 = true" , 4 ) . await ?;
1395- assert_eq ! ( results. len( ) , 1 ) ;
13961402
13971403 let expected = vec ! [
13981404 "+----+------+" ,
@@ -1414,7 +1420,6 @@ mod tests {
14141420 async fn aggregate_grouped_empty ( ) -> Result < ( ) > {
14151421 let results =
14161422 execute ( "SELECT c1, AVG(c2) FROM test WHERE c1 = 123 GROUP BY c1" , 4 ) . await ?;
1417- assert_eq ! ( results. len( ) , 1 ) ;
14181423
14191424 let expected = vec ! [ "++" , "||" , "++" , "++" ] ;
14201425 assert_batches_sorted_eq ! ( expected, & results) ;
@@ -1425,7 +1430,6 @@ mod tests {
14251430 #[ tokio:: test]
14261431 async fn aggregate_grouped_max ( ) -> Result < ( ) > {
14271432 let results = execute ( "SELECT c1, MAX(c2) FROM test GROUP BY c1" , 4 ) . await ?;
1428- assert_eq ! ( results. len( ) , 1 ) ;
14291433
14301434 let expected = vec ! [
14311435 "+----+---------+" ,
@@ -1445,7 +1449,6 @@ mod tests {
14451449 #[ tokio:: test]
14461450 async fn aggregate_grouped_min ( ) -> Result < ( ) > {
14471451 let results = execute ( "SELECT c1, MIN(c2) FROM test GROUP BY c1" , 4 ) . await ?;
1448- assert_eq ! ( results. len( ) , 1 ) ;
14491452
14501453 let expected = vec ! [
14511454 "+----+---------+" ,
@@ -1629,7 +1632,6 @@ mod tests {
16291632 #[ tokio:: test]
16301633 async fn count_aggregated ( ) -> Result < ( ) > {
16311634 let results = execute ( "SELECT c1, COUNT(c2) FROM test GROUP BY c1" , 4 ) . await ?;
1632- assert_eq ! ( results. len( ) , 1 ) ;
16331635
16341636 let expected = vec ! [
16351637 "+----+-----------+" ,
@@ -1681,7 +1683,6 @@ mod tests {
16811683 & mut ctx,
16821684 "SELECT date_trunc('week', t1) as week, SUM(c2) FROM test GROUP BY date_trunc('week', t1)" ,
16831685 ) . await ?;
1684- assert_eq ! ( results. len( ) , 1 ) ;
16851686
16861687 let expected = vec ! [
16871688 "+---------------------+---------+" ,
@@ -1925,7 +1926,6 @@ mod tests {
19251926 ] ;
19261927
19271928 let results = run_count_distinct_integers_aggregated_scenario ( partitions) . await ?;
1928- assert_eq ! ( results. len( ) , 1 ) ;
19291929
19301930 let expected = vec ! [
19311931 "+---------+-----------------+------------------------+-------------------------+-------------------------+-------------------------+-------------------------+--------------------------+--------------------------+--------------------------+" ,
@@ -1952,7 +1952,6 @@ mod tests {
19521952 ] ;
19531953
19541954 let results = run_count_distinct_integers_aggregated_scenario ( partitions) . await ?;
1955- assert_eq ! ( results. len( ) , 1 ) ;
19561955
19571956 let expected = vec ! [
19581957 "+---------+-----------------+------------------------+-------------------------+-------------------------+-------------------------+-------------------------+--------------------------+--------------------------+--------------------------+" ,
0 commit comments