@@ -32,6 +32,7 @@ use crate::IntoArray;
3232use crate :: VortexSessionExecute ;
3333use crate :: array_session;
3434use crate :: arrays:: Bool ;
35+ use crate :: arrays:: BoolArray ;
3536use crate :: arrays:: ConstantArray ;
3637use crate :: arrays:: FixedSizeList ;
3738use crate :: arrays:: Primitive ;
@@ -190,22 +191,30 @@ fn packed_boolean_payload_uses_allocator(
190191 . with_allocator ( allocator) ;
191192
192193 let output = match ( multiversioned, traversal) {
193- ( false , Traversal :: Infallible ) => {
194- execute_owned_infallible_bool :: < ( i64 , ) , false > ( & args, & mut ctx, |( value, ) | value > 2 ) ?
195- }
196- ( true , Traversal :: Infallible ) => {
197- execute_owned_infallible_bool :: < ( i64 , ) , true > ( & args, & mut ctx, |( value, ) | value > 2 ) ?
198- }
194+ ( false , Traversal :: Infallible ) => execute_owned_infallible_bool :: < ( i64 , ) , false > (
195+ & args,
196+ & mut ctx,
197+ Validity :: NonNullable ,
198+ |( value, ) | value > 2 ,
199+ ) ?,
200+ ( true , Traversal :: Infallible ) => execute_owned_infallible_bool :: < ( i64 , ) , true > (
201+ & args,
202+ & mut ctx,
203+ Validity :: NonNullable ,
204+ |( value, ) | value > 2 ,
205+ ) ?,
199206 ( false , Traversal :: Fallible ) => execute_owned_bool :: < ( i64 , ) , ( ) , bool , false > (
200207 & args,
201208 & mut ctx,
209+ Validity :: NonNullable ,
202210 |_| ( ) ,
203211 |_, ( value, ) | ( value > 2 , false ) ,
204212 |_| Ok ( ( ) ) ,
205213 ) ?,
206214 ( true , Traversal :: Fallible ) => execute_owned_bool :: < ( i64 , ) , ( ) , bool , true > (
207215 & args,
208216 & mut ctx,
217+ Validity :: NonNullable ,
209218 |_| ( ) ,
210219 |_, ( value, ) | ( value > 2 , false ) ,
211220 |_| Ok ( ( ) ) ,
@@ -347,8 +356,12 @@ fn empty_outputs_and_zero_width_rows_do_not_allocate_payloads() -> VortexResult<
347356
348357 let primitive =
349358 execute_owned_infallible :: < ( i64 , ) , i64 , ( ) > ( & args, & mut ctx, |_| ( ) , |_, ( value, ) | value) ?;
350- let boolean =
351- execute_owned_infallible_bool :: < ( i64 , ) , false > ( & args, & mut ctx, |( value, ) | value > 0 ) ?;
359+ let boolean = execute_owned_infallible_bool :: < ( i64 , ) , false > (
360+ & args,
361+ & mut ctx,
362+ Validity :: NonNullable ,
363+ |( value, ) | value > 0 ,
364+ ) ?;
352365 let scalar = execute_sink :: < ( i64 , ) , ( ) , UninitElementSink < i64 > , _ > (
353366 & args,
354367 & ( ) ,
@@ -495,3 +508,32 @@ fn zero_sized_output_uses_its_own_storage(#[case] traversal: Traversal) -> Vorte
495508
496509 Ok ( ( ) )
497510}
511+
512+ #[ rstest]
513+ fn packed_boolean_attaches_validity (
514+ #[ values( false , true ) ] multiversioned : bool ,
515+ ) -> VortexResult < ( ) > {
516+ let values = PrimitiveArray :: from_iter ( [ 1_i64 , 2 , 3 , 4 ] ) . into_array ( ) ;
517+ let args = VecExecutionArgs :: new ( vec ! [ values] , 4 ) ;
518+ let validity = Validity :: from_iter ( [ true , false , true , true ] ) ;
519+ let mut ctx = array_session ( ) . create_execution_ctx ( ) ;
520+
521+ let output = if multiversioned {
522+ execute_owned_infallible_bool :: < ( i64 , ) , true > ( & args, & mut ctx, validity, |( value, ) | {
523+ value > 2
524+ } ) ?
525+ } else {
526+ execute_owned_infallible_bool :: < ( i64 , ) , false > ( & args, & mut ctx, validity, |( value, ) | {
527+ value > 2
528+ } ) ?
529+ } ;
530+
531+ assert ! ( output. is:: <Bool >( ) ) ;
532+ let expected = BoolArray :: new (
533+ [ false , false , true , true ] . into_iter ( ) . collect ( ) ,
534+ Validity :: from_iter ( [ true , false , true , true ] ) ,
535+ )
536+ . into_array ( ) ;
537+ assert_arrays_eq ! ( & output, & expected, & mut ctx) ;
538+ Ok ( ( ) )
539+ }
0 commit comments