File tree Expand file tree Collapse file tree
vortex-array/src/aggregate_fn/fns/mean Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -220,25 +220,14 @@ impl AggregateFnVTable for Mean {
220220 . map ( |( s, c) | if * c == 0 { 0.0 } else { s / * c as f64 } )
221221 . collect ( ) ;
222222
223- let validity = match validity_mask {
224- Mask :: AllTrue ( _) => {
225- let valid_bits: Vec < bool > = count_values. iter ( ) . map ( |c| * c > 0 ) . collect ( ) ;
226- if valid_bits. iter ( ) . all ( |v| * v) {
227- Validity :: AllValid
228- } else {
229- Validity :: from_iter ( valid_bits)
230- }
231- }
232- Mask :: AllFalse ( _) => Validity :: AllInvalid ,
233- Mask :: Values ( v) => {
234- let valid_bits: Vec < bool > = count_values
235- . iter ( )
236- . zip ( v. bit_buffer ( ) . iter ( ) )
237- . map ( |( c, group_valid) | group_valid && * c > 0 )
238- . collect ( ) ;
239- Validity :: from_iter ( valid_bits)
240- }
241- } ;
223+ // A mean is valid when the group itself was valid AND had at least one
224+ // non-null element (count > 0).
225+ let validity = Validity :: from_iter (
226+ count_values
227+ . iter ( )
228+ . enumerate ( )
229+ . map ( |( i, c) | validity_mask. value ( i) && * c > 0 ) ,
230+ ) ;
242231
243232 Ok ( PrimitiveArray :: new ( means, validity) . into_array ( ) )
244233 }
You can’t perform that action at this time.
0 commit comments