This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new 21e9ceb586 Support parsing for old style FixedSizeList (#8882)
21e9ceb586 is described below

commit 21e9ceb58612a540f19e44b139b490bf81f7d0f2
Author: Andrew Lamb <[email protected]>
AuthorDate: Thu Nov 20 09:43:51 2025 -0500

    Support parsing for old style FixedSizeList (#8882)
    
    # Which issue does this PR close?
    
    
    - Closes https://github.com/apache/arrow-rs/issues/8880
    
    # Rationale for this change
    
    - https://github.com/apache/arrow-rs/pull/8649 change the default
    display for List and LargeList and FixedSizeList, and changed the
    parsing code to match.
    
    However, to maintain backwards compatibility we also need to support the
    old syntax too
    
    # What changes are included in this PR?
    
    WIP
    
    # Are these changes tested?
    
    WIP
    
    
    # Are there any user-facing changes?
---
 arrow-schema/src/datatype_parse.rs | 41 ++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)

diff --git a/arrow-schema/src/datatype_parse.rs 
b/arrow-schema/src/datatype_parse.rs
index 4ad32f59aa..0bb8d629e2 100644
--- a/arrow-schema/src/datatype_parse.rs
+++ b/arrow-schema/src/datatype_parse.rs
@@ -173,14 +173,35 @@ impl<'a> Parser<'a> {
     }
 
     /// Parses the FixedSizeList type (called after `FixedSizeList` has been 
consumed)
-    /// E.g: FixedSizeList(5 x nullable Int64, field: 'foo')
+    ///
+    /// Examples:
+    /// * `FixedSizeList(5 x nullable Int64, field: 'foo')`
+    /// * `FixedSizeList(4, Int64)`
+    ///
     fn parse_fixed_size_list(&mut self) -> ArrowResult<DataType> {
         self.expect_token(Token::LParen)?;
         let length = self.parse_i32("FixedSizeList")?;
-        self.expect_token(Token::X)?;
-        let field = self.parse_list_field("FixedSizeList")?;
-        self.expect_token(Token::RParen)?;
-        Ok(DataType::FixedSizeList(Arc::new(field), length))
+        match self.next_token()? {
+            // `FixedSizeList(5 x nullable Int64, field: 'foo')` format
+            Token::X => {
+                let field = self.parse_list_field("FixedSizeList")?;
+                self.expect_token(Token::RParen)?;
+                Ok(DataType::FixedSizeList(Arc::new(field), length))
+            }
+            // `FixedSizeList(4, Int64)` format
+            Token::Comma => {
+                let data_type = self.parse_next_type()?;
+                self.expect_token(Token::RParen)?;
+                Ok(DataType::FixedSizeList(
+                    Arc::new(Field::new_list_field(data_type, true)),
+                    length,
+                ))
+            }
+            tok => Err(make_error(
+                self.val,
+                &format!("Expected 'x' or ',' after length for FixedSizeList, 
got '{tok}'"),
+            )),
+        }
     }
 
     /// Parses the next timeunit
@@ -1199,9 +1220,9 @@ mod test {
         use IntervalUnit::*;
         use TimeUnit::*;
         // List below created with:
-        // for t in list_datatypes() {
-        // println!(r#"("{t}", {t:?}),"#)
-        // }
+        for t in list_datatypes() {
+            println!(r#"("{t}", {t:?}),"#);
+        }
         // (string to parse, expected DataType)
         let cases = [
             ("Timestamp(Nanosecond, None)", Timestamp(Nanosecond, None)),
@@ -1360,6 +1381,10 @@ mod test {
                 ])),
             ),
             (r#"Struct()"#, Struct(Fields::empty())),
+            (
+                "FixedSizeList(4, Int64)",
+                FixedSizeList(Arc::new(Field::new_list_field(Int64, true)), 4),
+            ),
         ];
 
         for (data_type_string, expected_data_type) in cases {

Reply via email to