44use vortex_array:: ArrayRef ;
55use vortex_array:: ArrayView ;
66use vortex_array:: IntoArray ;
7- use vortex_array:: LEGACY_SESSION ;
8- use vortex_array:: VortexSessionExecute ;
97use vortex_array:: builtins:: ArrayBuiltins ;
108use vortex_array:: dtype:: DType ;
119use vortex_array:: scalar_fn:: fns:: cast:: CastReduce ;
@@ -18,8 +16,6 @@ impl CastReduce for RunEnd {
1816 // Cast the values array to the target type
1917 let casted_values = array. values ( ) . cast ( dtype. clone ( ) ) ?;
2018
21- // TODO(ctx): trait fixes - CastReduce::cast has a fixed signature.
22- let mut ctx = LEGACY_SESSION . create_execution_ctx ( ) ;
2319 // SAFETY: casting does not affect the ends being valid
2420 unsafe {
2521 Ok ( Some (
@@ -28,7 +24,6 @@ impl CastReduce for RunEnd {
2824 casted_values,
2925 array. offset ( ) ,
3026 array. len ( ) ,
31- & mut ctx,
3227 )
3328 . into_array ( ) ,
3429 ) )
@@ -38,9 +33,10 @@ impl CastReduce for RunEnd {
3833
3934#[ cfg( test) ]
4035mod tests {
36+ use std:: sync:: LazyLock ;
37+
4138 use rstest:: rstest;
4239 use vortex_array:: IntoArray ;
43- use vortex_array:: LEGACY_SESSION ;
4440 use vortex_array:: VortexSessionExecute ;
4541 use vortex_array:: arrays:: BoolArray ;
4642 use vortex_array:: arrays:: PrimitiveArray ;
@@ -50,14 +46,19 @@ mod tests {
5046 use vortex_array:: dtype:: DType ;
5147 use vortex_array:: dtype:: Nullability ;
5248 use vortex_array:: dtype:: PType ;
49+ use vortex_array:: session:: ArraySession ;
5350 use vortex_buffer:: buffer;
51+ use vortex_session:: VortexSession ;
5452
5553 use crate :: RunEnd ;
5654 use crate :: RunEndArray ;
5755
56+ static SESSION : LazyLock < VortexSession > =
57+ LazyLock :: new ( || VortexSession :: empty ( ) . with :: < ArraySession > ( ) ) ;
58+
5859 #[ test]
5960 fn test_cast_runend_i32_to_i64 ( ) {
60- let mut ctx = LEGACY_SESSION . create_execution_ctx ( ) ;
61+ let mut ctx = SESSION . create_execution_ctx ( ) ;
6162 let runend = RunEnd :: try_new (
6263 buffer ! [ 3u64 , 5 , 8 , 10 ] . into_array ( ) ,
6364 buffer ! [ 100i32 , 200 , 100 , 300 ] . into_array ( ) ,
@@ -98,7 +99,7 @@ mod tests {
9899
99100 #[ test]
100101 fn test_cast_runend_nullable ( ) {
101- let mut ctx = LEGACY_SESSION . create_execution_ctx ( ) ;
102+ let mut ctx = SESSION . create_execution_ctx ( ) ;
102103 let runend = RunEnd :: try_new (
103104 buffer ! [ 2u64 , 4 , 7 ] . into_array ( ) ,
104105 PrimitiveArray :: from_option_iter ( [ Some ( 10i32 ) , None , Some ( 20 ) ] ) . into_array ( ) ,
@@ -118,7 +119,7 @@ mod tests {
118119
119120 #[ test]
120121 fn test_cast_runend_with_offset ( ) {
121- let mut ctx = LEGACY_SESSION . create_execution_ctx ( ) ;
122+ let mut ctx = SESSION . create_execution_ctx ( ) ;
122123 // Create a RunEndArray: [100, 100, 100, 200, 200, 300, 300, 300, 300, 300]
123124 let runend = RunEnd :: try_new (
124125 buffer ! [ 3u64 , 5 , 10 ] . into_array ( ) ,
@@ -174,7 +175,7 @@ mod tests {
174175 ctx,
175176 ) . unwrap( ) ) ]
176177 fn test_cast_runend_conformance ( #[ case] build : RunEndBuilder ) {
177- let mut ctx = LEGACY_SESSION . create_execution_ctx ( ) ;
178+ let mut ctx = SESSION . create_execution_ctx ( ) ;
178179 let array = build ( & mut ctx) ;
179180 test_cast_conformance ( & array. into_array ( ) ) ;
180181 }
0 commit comments