'How to build an Apache Arrow message containing a list of structs with arrow-rs?

I'm using the arrow-rs crate (version 4.4) to declared the following schema:

Schema::new(vec![
            Field::new("name", DataType::Utf8, false),
            Field::new("attributes", DataType::List(
                Box::new(Field::new(
                    "attr",
                    DataType::Struct(vec![
                        Field::new("name", DataType::Utf8, false),
                        Field::new("value", DataType::Utf8, false),
                    ]),
                    true,
                ))
            ), true),
])

I'm struggling to find a complete example building a record batch from this type of schema containing a list of structs.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source