@@ -118,11 +118,11 @@ pub enum vx_validity_type {
118118
119119#[ repr( C ) ]
120120pub struct vx_validity {
121- r#type : vx_validity_type ,
121+ pub r#type : vx_validity_type ,
122122 /// If type is not VX_VALIDITY_ARRAY, this is NULL.
123123 /// If type is VX_VALIDITY_ARRAY, this is set to an owned boolean validity
124124 /// array which must be freed by the caller.
125- array : * const vx_array ,
125+ pub array : * const vx_array ,
126126}
127127
128128impl From < & vx_validity > for Validity {
@@ -281,7 +281,7 @@ unsafe fn primitive_from_raw<T: vortex::dtype::NativePType>(
281281///
282282/// Example:
283283///
284- /// const vx_error* error = nullptr ;
284+ /// const vx_error* error = NULL ;
285285/// vx_validity validity = {};
286286/// validity.type = VX_VALIDITY_NON_NULLABLE;
287287/// uint32_t buffer[] = {1, 2, 3};
@@ -425,7 +425,6 @@ mod tests {
425425 use vortex:: array:: IntoArray ;
426426 use vortex:: array:: arrays:: BoolArray ;
427427 use vortex:: array:: arrays:: PrimitiveArray ;
428- use vortex:: array:: arrays:: StructArray ;
429428 use vortex:: array:: arrays:: VarBinViewArray ;
430429 use vortex:: array:: validity:: Validity ;
431430 use vortex:: buffer:: buffer;
@@ -434,15 +433,28 @@ mod tests {
434433 use vortex:: expr:: eq;
435434 use vortex:: expr:: lit;
436435 use vortex:: expr:: root;
436+ use vortex_array:: arrays:: StructArray ;
437437
438438 use crate :: array:: * ;
439439 use crate :: binary:: vx_binary_free;
440440 use crate :: dtype:: vx_dtype_get_variant;
441441 use crate :: dtype:: vx_dtype_variant;
442442 use crate :: error:: vx_error_free;
443+ use crate :: error:: vx_error_get_message;
443444 use crate :: expression:: vx_expression_free;
444445 use crate :: string:: vx_string_free;
445446
447+ fn assert_no_error ( error : * mut vx_error ) {
448+ if !error. is_null ( ) {
449+ let message;
450+ unsafe {
451+ message = vx_string:: as_str ( vx_error_get_message ( error) ) . to_owned ( ) ;
452+ vx_error_free ( error) ;
453+ }
454+ panic ! ( "{message}" ) ;
455+ }
456+ }
457+
446458 #[ test]
447459 // TODO(joe): enable once this is fixed https://github.com/Amanieu/parking_lot/issues/477
448460 #[ cfg_attr( miri, ignore) ]
@@ -491,7 +503,7 @@ mod tests {
491503
492504 let mut error = ptr:: null_mut ( ) ;
493505 let sliced = vx_array_slice ( ffi_array, 1 , 4 , & raw mut error) ;
494- assert ! ( error. is_null ( ) ) ;
506+ assert_no_error ( error) ;
495507 assert_eq ! ( vx_array_len( sliced) , 3 ) ;
496508 assert_eq ! ( vx_array_get_i32( sliced, 0 ) , 2 ) ;
497509 assert_eq ! ( vx_array_get_i32( sliced, 1 ) , 3 ) ;
@@ -515,14 +527,14 @@ mod tests {
515527
516528 let mut error = ptr:: null_mut ( ) ;
517529 assert ! ( !vx_array_element_is_invalid( ffi_array, 0 , & raw mut error) ) ;
518- assert ! ( error. is_null ( ) ) ;
530+ assert_no_error ( error) ;
519531 assert ! ( vx_array_element_is_invalid( ffi_array, 1 , & raw mut error) ) ;
520- assert ! ( error. is_null ( ) ) ;
532+ assert_no_error ( error) ;
521533 assert ! ( !vx_array_element_is_invalid( ffi_array, 2 , & raw mut error) ) ;
522- assert ! ( error. is_null ( ) ) ;
534+ assert_no_error ( error) ;
523535
524536 let null_count = vx_array_invalid_count ( ffi_array, & raw mut error) ;
525- assert ! ( error. is_null ( ) ) ;
537+ assert_no_error ( error) ;
526538 assert_eq ! ( null_count, 1 ) ;
527539
528540 vx_array_free ( ffi_array) ;
@@ -547,11 +559,11 @@ mod tests {
547559
548560 let mut error = ptr:: null_mut ( ) ;
549561 let field0 = vx_array_get_field ( ffi_array, 0 , & raw mut error) ;
550- assert ! ( error. is_null ( ) ) ;
562+ assert_no_error ( error) ;
551563 assert_eq ! ( vx_array_len( field0) , 3 ) ;
552564
553565 let field1 = vx_array_get_field ( ffi_array, 1 , & raw mut error) ;
554- assert ! ( error. is_null ( ) ) ;
566+ assert_no_error ( error) ;
555567 assert_eq ! ( vx_array_len( field1) , 3 ) ;
556568 assert_eq ! ( vx_array_get_u8( field1, 0 ) , 30 ) ;
557569 assert_eq ! ( vx_array_get_u8( field1, 1 ) , 25 ) ;
@@ -592,7 +604,7 @@ mod tests {
592604 & raw const validity,
593605 & raw mut error,
594606 ) ;
595- assert ! ( error. is_null ( ) ) ;
607+ assert_no_error ( error) ;
596608 assert ! ( !ffi_i32. is_null( ) ) ;
597609
598610 assert ! ( vx_array_is_primitive( ffi_i32, vx_ptype:: PTYPE_I32 ) ) ;
@@ -610,7 +622,7 @@ mod tests {
610622 & raw const validity,
611623 & raw mut error,
612624 ) ;
613- assert ! ( error. is_null ( ) ) ;
625+ assert_no_error ( error) ;
614626 assert ! ( !ffi_u64. is_null( ) ) ;
615627 assert ! ( vx_array_is_primitive( ffi_u64, vx_ptype:: PTYPE_U64 ) ) ;
616628 assert_eq ! ( vx_array_get_u64( ffi_u64, 0 ) , u64 :: MAX ) ;
@@ -627,7 +639,7 @@ mod tests {
627639 & raw const validity,
628640 & raw mut error,
629641 ) ;
630- assert ! ( error. is_null ( ) ) ;
642+ assert_no_error ( error) ;
631643 assert ! ( !ffi_f64. is_null( ) ) ;
632644 assert ! ( vx_array_is_primitive( ffi_f64, vx_ptype:: PTYPE_F64 ) ) ;
633645 assert_eq ! ( vx_array_get_f64( ffi_f64, 0 ) , f64 :: NEG_INFINITY ) ;
@@ -646,7 +658,7 @@ mod tests {
646658 & raw const validity,
647659 & raw mut error,
648660 ) ;
649- assert ! ( error. is_null ( ) ) ;
661+ assert_no_error ( error) ;
650662 assert ! ( !ffi_f16. is_null( ) ) ;
651663 assert_eq ! ( vx_array_get_f16( ffi_f16, 0 ) , f16:: from_f32( 1.0 ) ) ;
652664 assert_eq ! ( vx_array_get_f16( ffi_f16, 1 ) , f16:: from_f32( -0.5 ) ) ;
@@ -746,8 +758,8 @@ mod tests {
746758 vx_error_free ( error) ;
747759
748760 let res = vx_array_apply ( array, expression, & raw mut error) ;
761+ assert_no_error ( error) ;
749762 assert ! ( !res. is_null( ) ) ;
750- assert ! ( error. is_null( ) ) ;
751763 {
752764 let res = vx_array:: as_ref ( res) ;
753765 let buffer = res. to_bool ( ) . to_bit_buffer ( ) ;
0 commit comments