@@ -52,6 +52,19 @@ impl TryFrom<&pb::DType> for DType {
5252 nullable,
5353 ) )
5454 }
55+ DtypeType :: FixedSizeList ( fsl) => {
56+ let nullable = fsl. nullable . into ( ) ;
57+ Ok ( Self :: FixedSizeList (
58+ fsl. element_type
59+ . as_ref ( )
60+ . ok_or_else ( || vortex_err ! ( InvalidSerde : "Invalid fixed-size list element type" ) ) ?
61+ . as_ref ( )
62+ . try_into ( )
63+ . map ( Arc :: new) ?,
64+ fsl. size ,
65+ nullable,
66+ ) )
67+ }
5568 DtypeType :: Extension ( e) => Ok ( Self :: Extension (
5669 Arc :: new ( ExtDType :: new (
5770 ExtID :: from ( e. id . as_str ( ) ) ,
@@ -72,36 +85,39 @@ impl From<&DType> for pb::DType {
7285 Self {
7386 dtype_type : Some ( match value {
7487 DType :: Null => DtypeType :: Null ( pb:: Null { } ) ,
75- DType :: Bool ( n ) => DtypeType :: Bool ( pb:: Bool {
76- nullable : ( * n ) . into ( ) ,
88+ DType :: Bool ( null ) => DtypeType :: Bool ( pb:: Bool {
89+ nullable : ( * null ) . into ( ) ,
7790 } ) ,
78- DType :: Primitive ( ptype, n ) => DtypeType :: Primitive ( pb:: Primitive {
91+ DType :: Primitive ( ptype, null ) => DtypeType :: Primitive ( pb:: Primitive {
7992 r#type : pb:: PType :: from ( * ptype) . into ( ) ,
80- nullable : ( * n ) . into ( ) ,
93+ nullable : ( * null ) . into ( ) ,
8194 } ) ,
82- DType :: Decimal ( decimal, n ) => DtypeType :: Decimal ( pb:: Decimal {
95+ DType :: Decimal ( decimal, null ) => DtypeType :: Decimal ( pb:: Decimal {
8396 precision : decimal. precision ( ) as u32 ,
8497 scale : decimal. scale ( ) as i32 ,
85- nullable : ( * n ) . into ( ) ,
98+ nullable : ( * null ) . into ( ) ,
8699 } ) ,
87- DType :: Utf8 ( n ) => DtypeType :: Utf8 ( pb:: Utf8 {
88- nullable : ( * n ) . into ( ) ,
100+ DType :: Utf8 ( null ) => DtypeType :: Utf8 ( pb:: Utf8 {
101+ nullable : ( * null ) . into ( ) ,
89102 } ) ,
90- DType :: Binary ( n ) => DtypeType :: Binary ( pb:: Binary {
91- nullable : ( * n ) . into ( ) ,
103+ DType :: Binary ( null ) => DtypeType :: Binary ( pb:: Binary {
104+ nullable : ( * null ) . into ( ) ,
92105 } ) ,
93- DType :: Struct ( s, n ) => DtypeType :: Struct ( pb:: Struct {
106+ DType :: Struct ( s, null ) => DtypeType :: Struct ( pb:: Struct {
94107 names : s. names ( ) . iter ( ) . map ( |s| s. as_ref ( ) . to_string ( ) ) . collect ( ) ,
95108 dtypes : s. fields ( ) . map ( |d| Self :: from ( & d) ) . collect ( ) ,
96- nullable : ( * n ) . into ( ) ,
109+ nullable : ( * null ) . into ( ) ,
97110 } ) ,
98- DType :: List ( l , n ) => DtypeType :: List ( Box :: new ( pb:: List {
99- element_type : Some ( Box :: new ( l . as_ref ( ) . into ( ) ) ) ,
100- nullable : ( * n ) . into ( ) ,
111+ DType :: List ( edt , null ) => DtypeType :: List ( Box :: new ( pb:: List {
112+ element_type : Some ( Box :: new ( edt . as_ref ( ) . into ( ) ) ) ,
113+ nullable : ( * null ) . into ( ) ,
101114 } ) ) ,
102- DType :: FixedSizeList ( ..) => {
103- // TODO(connor)[FixedSizeList]
104- unimplemented ! ( "TODO(connor)[FixedSizeList]" )
115+ DType :: FixedSizeList ( edt, size, null) => {
116+ DtypeType :: FixedSizeList ( Box :: new ( pb:: FixedSizeList {
117+ element_type : Some ( Box :: new ( edt. as_ref ( ) . into ( ) ) ) ,
118+ size : * size,
119+ nullable : ( * null) . into ( ) ,
120+ } ) )
105121 }
106122 DType :: Extension ( e) => DtypeType :: Extension ( Box :: new ( pb:: Extension {
107123 id : e. id ( ) . as_ref ( ) . into ( ) ,
@@ -259,6 +275,7 @@ mod tests {
259275 #[ test]
260276 fn test_list_round_trip ( ) {
261277 let list_types = vec ! [
278+ // List types
262279 DType :: List (
263280 Arc :: new( DType :: Primitive ( PType :: I32 , Nullability :: NonNullable ) ) ,
264281 Nullability :: Nullable ,
@@ -274,6 +291,26 @@ mod tests {
274291 ) ) ,
275292 Nullability :: NonNullable ,
276293 ) ,
294+ // FixedSizeList types
295+ DType :: FixedSizeList (
296+ Arc :: new( DType :: Primitive ( PType :: I32 , Nullability :: NonNullable ) ) ,
297+ 3 ,
298+ Nullability :: Nullable ,
299+ ) ,
300+ DType :: FixedSizeList (
301+ Arc :: new( DType :: Utf8 ( Nullability :: Nullable ) ) ,
302+ 5 ,
303+ Nullability :: NonNullable ,
304+ ) ,
305+ DType :: FixedSizeList (
306+ Arc :: new( DType :: FixedSizeList (
307+ Arc :: new( DType :: Primitive ( PType :: F64 , Nullability :: NonNullable ) ) ,
308+ 2 ,
309+ Nullability :: Nullable ,
310+ ) ) ,
311+ 4 ,
312+ Nullability :: NonNullable ,
313+ ) ,
277314 ] ;
278315
279316 for dtype in list_types {
0 commit comments