@@ -49,14 +49,15 @@ mod tests {
4949 use std:: sync:: LazyLock ;
5050
5151 use rstest:: rstest;
52+ use vortex_buffer:: BitBuffer ;
5253 use vortex_buffer:: buffer;
5354 use vortex_session:: VortexSession ;
5455
56+ use crate :: ArrayRef ;
5557 use crate :: IntoArray ;
56- #[ expect( deprecated) ]
57- use crate :: ToCanonical as _;
5858 use crate :: VortexSessionExecute ;
5959 use crate :: arrays:: Dict ;
60+ use crate :: arrays:: DictArray ;
6061 use crate :: arrays:: PrimitiveArray ;
6162 use crate :: arrays:: dict:: DictArraySlotsExt ;
6263 use crate :: assert_arrays_eq;
@@ -66,13 +67,15 @@ mod tests {
6667 use crate :: dtype:: DType ;
6768 use crate :: dtype:: Nullability ;
6869 use crate :: dtype:: PType ;
70+ use crate :: validity:: Validity ;
6971
7072 static SESSION : LazyLock < VortexSession > = LazyLock :: new ( crate :: array_session) ;
7173
7274 #[ test]
7375 fn test_cast_dict_to_wider_type ( ) {
76+ let ctx = & mut SESSION . create_execution_ctx ( ) ;
7477 let values = buffer ! [ 1i32 , 2 , 3 , 2 , 1 ] . into_array ( ) ;
75- let dict = dict_encode ( & values, & mut SESSION . create_execution_ctx ( ) ) . unwrap ( ) ;
78+ let dict = dict_encode ( & values, ctx ) . unwrap ( ) ;
7679
7780 let casted = dict
7881 . into_array ( )
@@ -83,13 +86,8 @@ mod tests {
8386 & DType :: Primitive ( PType :: I64 , Nullability :: NonNullable )
8487 ) ;
8588
86- #[ expect( deprecated) ]
87- let decoded = casted. to_primitive ( ) ;
88- assert_arrays_eq ! (
89- decoded,
90- PrimitiveArray :: from_iter( [ 1i64 , 2 , 3 , 2 , 1 ] ) ,
91- & mut SESSION . create_execution_ctx( )
92- ) ;
89+ let decoded = casted. into_array ( ) . execute :: < PrimitiveArray > ( ctx) . unwrap ( ) ;
90+ assert_arrays_eq ! ( decoded, PrimitiveArray :: from_iter( [ 1i64 , 2 , 3 , 2 , 1 ] ) , ctx) ;
9391 }
9492
9593 #[ test]
@@ -110,9 +108,10 @@ mod tests {
110108
111109 #[ test]
112110 fn test_cast_dict_allvalid_to_nonnullable_and_back ( ) {
111+ let ctx = & mut SESSION . create_execution_ctx ( ) ;
113112 // Create an AllValid dict array (no nulls)
114113 let values = buffer ! [ 10i32 , 20 , 30 , 40 ] . into_array ( ) ;
115- let dict = dict_encode ( & values, & mut SESSION . create_execution_ctx ( ) ) . unwrap ( ) ;
114+ let dict = dict_encode ( & values, ctx ) . unwrap ( ) ;
116115
117116 // Verify initial state - codes should be NonNullable, values should be NonNullable
118117 assert_eq ! ( dict. codes( ) . dtype( ) . nullability( ) , Nullability :: NonNullable ) ;
@@ -173,37 +172,30 @@ mod tests {
173172 ) ;
174173
175174 // Verify values are unchanged
176- #[ expect( deprecated) ]
177- let original_values = dict. as_array ( ) . to_primitive ( ) ;
178- #[ expect( deprecated) ]
179- let final_values = back_to_non_nullable. to_primitive ( ) ;
180- assert_arrays_eq ! (
181- original_values,
182- final_values,
183- & mut SESSION . create_execution_ctx( )
184- ) ;
175+ let original_values = dict. into_array ( ) . execute :: < PrimitiveArray > ( ctx) . unwrap ( ) ;
176+
177+ let final_values = back_to_non_nullable. execute :: < PrimitiveArray > ( ctx) . unwrap ( ) ;
178+ assert_arrays_eq ! ( original_values, final_values, ctx) ;
185179 }
186180
187181 #[ rstest]
188182 #[ case( dict_encode( & buffer![ 1i32 , 2 , 3 , 2 , 1 , 3 ] . into_array( ) , & mut SESSION . create_execution_ctx( ) ) . unwrap( ) . into_array( ) ) ]
189183 #[ case( dict_encode( & buffer![ 100u32 , 200 , 100 , 300 , 200 ] . into_array( ) , & mut SESSION . create_execution_ctx( ) ) . unwrap( ) . into_array( ) ) ]
190184 #[ case( dict_encode( & PrimitiveArray :: from_option_iter( [ Some ( 1i32 ) , None , Some ( 2 ) , Some ( 1 ) , None ] ) . into_array( ) , & mut SESSION . create_execution_ctx( ) ) . unwrap( ) . into_array( ) ) ]
191185 #[ case( dict_encode( & buffer![ 1.5f32 , 2.5 , 1.5 , 3.5 ] . into_array( ) , & mut SESSION . create_execution_ctx( ) ) . unwrap( ) . into_array( ) ) ]
192- fn test_cast_dict_conformance ( #[ case] array : crate :: ArrayRef ) {
186+ fn test_cast_dict_conformance ( #[ case] array : ArrayRef ) {
193187 test_cast_conformance ( & array) ;
194188 }
195189
196190 #[ test]
197191 fn test_cast_dict_with_unreferenced_null_values_to_nonnullable ( ) {
198- use crate :: arrays:: DictArray ;
199- use crate :: validity:: Validity ;
200-
192+ let ctx = & mut SESSION . create_execution_ctx ( ) ;
201193 // Create a dict with nullable values that have unreferenced null entries.
202194 // Values: [1.0, null, 3.0] (index 1 is null but no code points to it)
203195 // Codes: [0, 2, 0] (only reference indices 0 and 2, never 1)
204196 let values = PrimitiveArray :: new (
205197 buffer ! [ 1.0f64 , 0.0f64 , 3.0f64 ] ,
206- Validity :: from ( vortex_buffer :: BitBuffer :: from ( vec ! [ true , false , true ] ) ) ,
198+ Validity :: from ( BitBuffer :: from ( vec ! [ true , false , true ] ) ) ,
207199 )
208200 . into_array ( ) ;
209201 let codes = buffer ! [ 0u32 , 2 , 0 ] . into_array ( ) ;
@@ -228,12 +220,6 @@ mod tests {
228220 casted. dtype( ) ,
229221 & DType :: Primitive ( PType :: F64 , Nullability :: NonNullable )
230222 ) ;
231- #[ expect( deprecated) ]
232- let casted_prim = casted. to_primitive ( ) ;
233- assert_arrays_eq ! (
234- casted_prim,
235- PrimitiveArray :: from_iter( [ 1.0f64 , 3.0 , 1.0 ] ) ,
236- & mut SESSION . create_execution_ctx( )
237- ) ;
223+ assert_arrays_eq ! ( casted, PrimitiveArray :: from_iter( [ 1.0f64 , 3.0 , 1.0 ] ) , ctx) ;
238224 }
239225}
0 commit comments