@@ -167,8 +167,12 @@ impl Scalar {
167167 /// # Errors
168168 ///
169169 /// Returns an error if type validation fails.
170- pub fn from_proto_value ( value : & pb:: ScalarValue , dtype : & DType ) -> VortexResult < Self > {
171- let scalar_value = ScalarValue :: from_proto ( value, dtype) ?;
170+ pub fn from_proto_value (
171+ value : & pb:: ScalarValue ,
172+ dtype : & DType ,
173+ session : & VortexSession ,
174+ ) -> VortexResult < Self > {
175+ let scalar_value = ScalarValue :: from_proto ( value, dtype, session) ?;
172176
173177 Scalar :: try_new ( dtype. clone ( ) , scalar_value)
174178 }
@@ -192,7 +196,7 @@ impl Scalar {
192196 . as_ref ( )
193197 . ok_or_else ( || vortex_err ! ( Serde : "Scalar missing value" ) ) ?;
194198
195- let value: Option < ScalarValue > = ScalarValue :: from_proto ( pb_scalar_value, & dtype) ?;
199+ let value: Option < ScalarValue > = ScalarValue :: from_proto ( pb_scalar_value, & dtype, session ) ?;
196200
197201 Scalar :: try_new ( dtype, value)
198202 }
@@ -207,9 +211,13 @@ impl ScalarValue {
207211 /// # Errors
208212 ///
209213 /// Returns an error if decoding or type validation fails.
210- pub fn from_proto_bytes ( bytes : & [ u8 ] , dtype : & DType ) -> VortexResult < Option < Self > > {
214+ pub fn from_proto_bytes (
215+ bytes : & [ u8 ] ,
216+ dtype : & DType ,
217+ session : & VortexSession ,
218+ ) -> VortexResult < Option < Self > > {
211219 let proto = pb:: ScalarValue :: decode ( bytes) ?;
212- Self :: from_proto ( & proto, dtype)
220+ Self :: from_proto ( & proto, dtype, session )
213221 }
214222
215223 /// Creates a [`ScalarValue`] from its [protobuf](pb::ScalarValue) representation.
@@ -220,7 +228,11 @@ impl ScalarValue {
220228 /// # Errors
221229 ///
222230 /// Returns an error if the protobuf value cannot be converted to the given [`DType`].
223- pub fn from_proto ( value : & pb:: ScalarValue , dtype : & DType ) -> VortexResult < Option < Self > > {
231+ pub fn from_proto (
232+ value : & pb:: ScalarValue ,
233+ dtype : & DType ,
234+ session : & VortexSession ,
235+ ) -> VortexResult < Option < Self > > {
224236 let kind = value
225237 . kind
226238 . as_ref ( )
@@ -242,7 +254,7 @@ impl ScalarValue {
242254 Kind :: F64Value ( v) => f64_from_proto ( * v, dtype) ?,
243255 Kind :: StringValue ( s) => string_from_proto ( s, dtype) ?,
244256 Kind :: BytesValue ( b) => bytes_from_proto ( b, dtype) ?,
245- Kind :: ListValue ( v) => list_from_proto ( v, dtype) ?,
257+ Kind :: ListValue ( v) => list_from_proto ( v, dtype, session ) ?,
246258 } ) )
247259 }
248260}
@@ -415,14 +427,22 @@ fn bytes_from_proto(bytes: &[u8], dtype: &DType) -> VortexResult<ScalarValue> {
415427}
416428
417429/// Deserialize a [`ScalarValue::List`] from a protobuf `ListValue`.
418- fn list_from_proto ( v : & ListValue , dtype : & DType ) -> VortexResult < ScalarValue > {
430+ fn list_from_proto (
431+ v : & ListValue ,
432+ dtype : & DType ,
433+ session : & VortexSession ,
434+ ) -> VortexResult < ScalarValue > {
419435 let element_dtype = dtype
420436 . as_list_element_opt ( )
421437 . ok_or_else ( || vortex_err ! ( Serde : "expected List dtype for ListValue, got {dtype}" ) ) ?;
422438
423439 let mut values = Vec :: with_capacity ( v. values . len ( ) ) ;
424440 for elem in v. values . iter ( ) {
425- values. push ( ScalarValue :: from_proto ( elem, element_dtype. as_ref ( ) ) ?) ;
441+ values. push ( ScalarValue :: from_proto (
442+ elem,
443+ element_dtype. as_ref ( ) ,
444+ session,
445+ ) ?) ;
426446 }
427447
428448 Ok ( ScalarValue :: List ( values) )
@@ -604,6 +624,7 @@ mod tests {
604624 let scalar_value = ScalarValue :: from_proto (
605625 & pb_scalar_value,
606626 & DType :: Primitive ( PType :: U64 , Nullability :: NonNullable ) ,
627+ & session ( ) ,
607628 )
608629 . unwrap ( ) ;
609630 assert_eq ! (
@@ -615,6 +636,7 @@ mod tests {
615636 let scalar_value_f16 = ScalarValue :: from_proto (
616637 & pb_scalar_value,
617638 & DType :: Primitive ( PType :: F16 , Nullability :: Nullable ) ,
639+ & session ( ) ,
618640 )
619641 . unwrap ( ) ;
620642
@@ -651,6 +673,7 @@ mod tests {
651673 let read_back = ScalarValue :: from_proto (
652674 & pb_value,
653675 & DType :: Primitive ( PType :: F16 , Nullability :: NonNullable ) ,
676+ & session ( ) ,
654677 )
655678 . unwrap ( ) ;
656679
@@ -729,7 +752,7 @@ mod tests {
729752
730753 for ( name, value, dtype) in exact_roundtrip_cases {
731754 let pb_value = ScalarValue :: to_proto ( value. as_ref ( ) ) ;
732- let read_back = ScalarValue :: from_proto ( & pb_value, & dtype) . unwrap ( ) ;
755+ let read_back = ScalarValue :: from_proto ( & pb_value, & dtype, & session ( ) ) . unwrap ( ) ;
733756
734757 let original_debug = format ! ( "{value:?}" ) ;
735758 let roundtrip_debug = format ! ( "{read_back:?}" ) ;
@@ -764,7 +787,7 @@ mod tests {
764787
765788 for ( name, value, dtype, expected) in unsigned_cases {
766789 let pb_value = ScalarValue :: to_proto ( Some ( & value) ) ;
767- let read_back = ScalarValue :: from_proto ( & pb_value, & dtype) . unwrap ( ) ;
790+ let read_back = ScalarValue :: from_proto ( & pb_value, & dtype, & session ( ) ) . unwrap ( ) ;
768791
769792 match read_back. as_ref ( ) {
770793 Some ( ScalarValue :: Primitive ( pv) ) => {
@@ -808,7 +831,7 @@ mod tests {
808831
809832 for ( name, value, dtype, expected) in signed_cases {
810833 let pb_value = ScalarValue :: to_proto ( Some ( & value) ) ;
811- let read_back = ScalarValue :: from_proto ( & pb_value, & dtype) . unwrap ( ) ;
834+ let read_back = ScalarValue :: from_proto ( & pb_value, & dtype, & session ( ) ) . unwrap ( ) ;
812835
813836 match read_back. as_ref ( ) {
814837 Some ( ScalarValue :: Primitive ( pv) ) => {
@@ -837,7 +860,8 @@ mod tests {
837860 assert_eq ! (
838861 Scalar :: from_proto_value(
839862 & pb:: ScalarValue :: from( & v) ,
840- & DType :: Primitive ( PType :: U64 , Nullability :: Nullable )
863+ & DType :: Primitive ( PType :: U64 , Nullability :: Nullable ) ,
864+ & session( )
841865 )
842866 . unwrap( ) ,
843867 Scalar :: primitive( 0u64 , Nullability :: Nullable )
@@ -852,7 +876,8 @@ mod tests {
852876 assert_eq ! (
853877 Scalar :: from_proto_value(
854878 & pb:: ScalarValue :: from( & v) ,
855- & DType :: Primitive ( PType :: I64 , Nullability :: Nullable )
879+ & DType :: Primitive ( PType :: I64 , Nullability :: Nullable ) ,
880+ & session( )
856881 )
857882 . unwrap( ) ,
858883 Scalar :: primitive( 0i64 , Nullability :: Nullable )
0 commit comments