istvan-fodor opened a new issue, #5494:
URL: https://github.com/apache/arrow-rs/issues/5494

   Hi All,
   As per @alamb 's advice, I am cross posting my question from Discord. 
   
   I have a question about how to use ListBuilders with StructBuilders. 
   
   I am building an array that has a column with a list type. There are structs 
in the list. When I create a builder for the column, I am unable to append to 
it. Whenever I try to get a field builder for the structs, I am unable to do 
so. 
   
   I debugged through StructBuilder::make_builder and seems like everything is 
correctly created (List builder with StructBuilder type). I am attaching a 
small snippet that reproduces my issue. Any advice is very much appreciated! 
Thanks! 
   
   Here is an example code to reproduce my issue:
   
   ```rust
   use arrow::datatypes::{DataType, Field, Fields};
   use std::sync::Arc;
   
   fn main() {
       let mut status = arrow::array::builder::ListBuilder::new(
           arrow::array::StructBuilder::from_fields(status_schema(), 0),
       );
   
       let mut struct_builder: &mut arrow::array::StructBuilder = 
status.values();
   
       let mut list_builder_option = struct_builder
           
.field_builder::<arrow::array::builder::ListBuilder<arrow::array::StructBuilder>>(1usize)
           .unwrap();
   }
   
   pub fn status_schema() -> Vec<Field> {
       vec![
           Field::new("id", DataType::Utf8, true),
           Field::new(
               "values",
               DataType::List(Arc::new(Field::new(
                   "item",
                   DataType::Struct(Fields::from(key_value_schema())),
                   true,
               ))),
               true,
           ),
       ]
   }
   pub fn key_value_schema() -> Vec<Field> {
       vec![
           Field::new("key", DataType::Utf8, true),
           Field::new("value", DataType::Utf8, true),
       ]
   }
   ```
   
   The line `let mut list_builder_option = 
struct_builder.field_builder::<arrow::array::builder::ListBuilder<arrow::array::StructBuilder>>(1usize).unwrap();`
 panics. I expected it to to return a builder where I can start adding the 
struct fields.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to