@@ -815,6 +815,7 @@ impl GroupedHashAggregateStream {
815
815
} else {
816
816
self . schema ( )
817
817
} ;
818
+
818
819
if self . group_values . is_empty ( ) {
819
820
return Ok ( VecDeque :: from ( [ RecordBatch :: new_empty ( schema) ] ) ) ;
820
821
}
@@ -832,14 +833,14 @@ impl GroupedHashAggregateStream {
832
833
let mut rows_count_before_cur_block = 0 ;
833
834
for output_block in output. iter_mut ( ) {
834
835
let block_start = rows_count_before_cur_block;
835
- let block_end =
836
- rows_count_before_cur_block + output_block [ 0 ] . len ( ) ;
836
+ let block_len= output_block [ 0 ] . len ( ) ;
837
+
837
838
output_block. reserve ( states. len ( ) ) ;
838
839
for state in states. iter ( ) {
839
- output_block. push ( state. slice ( block_start, block_end ) )
840
+ output_block. push ( state. slice ( block_start, block_len ) )
840
841
}
841
842
842
- rows_count_before_cur_block = output_block [ 0 ] . len ( ) ;
843
+ rows_count_before_cur_block += block_len ;
843
844
}
844
845
}
845
846
_ if spilling => {
@@ -849,14 +850,14 @@ impl GroupedHashAggregateStream {
849
850
let mut rows_count_before_cur_block = 0 ;
850
851
for output_block in output. iter_mut ( ) {
851
852
let block_start = rows_count_before_cur_block;
852
- let block_end =
853
- rows_count_before_cur_block + output_block [ 0 ] . len ( ) ;
853
+ let block_len = output_block [ 0 ] . len ( ) ;
854
+
854
855
output_block. reserve ( states. len ( ) ) ;
855
856
for state in states. iter ( ) {
856
- output_block. push ( state. slice ( block_start, block_end ) )
857
+ output_block. push ( state. slice ( block_start, block_len ) )
857
858
}
858
859
859
- rows_count_before_cur_block = output_block [ 0 ] . len ( ) ;
860
+ rows_count_before_cur_block += block_len ;
860
861
}
861
862
}
862
863
AggregateMode :: Final
@@ -867,10 +868,11 @@ impl GroupedHashAggregateStream {
867
868
let mut rows_count_before_cur_block = 0 ;
868
869
for output_block in output. iter_mut ( ) {
869
870
let block_start = rows_count_before_cur_block;
870
- let block_end =
871
- rows_count_before_cur_block + output_block[ 0 ] . len ( ) ;
872
- output_block. push ( state. slice ( block_start, block_end) ) ;
873
- rows_count_before_cur_block = output_block[ 0 ] . len ( ) ;
871
+ let block_len = output_block[ 0 ] . len ( ) ;
872
+
873
+ output_block. push ( state. slice ( block_start, block_len) ) ;
874
+
875
+ rows_count_before_cur_block += block_len;
874
876
}
875
877
}
876
878
}
0 commit comments