sdf-jkl commented on issue #8060:
URL: https://github.com/apache/arrow-rs/issues/8060#issuecomment-3189547981

   > > [@alamb](https://github.com/alamb) Can I confirm that for 
DataType::List(_) the converted array should be GenericListArray( for 
LargeList)?
   > 
   > I think the output should still be a `VariantArray`
   > 
   > each element of the output array should be `Variant::List`
   > 
   > Does that make sense?
   
   Yes this makes sense. 
   
   What I am now having trouble with is converting the inner lists into 
`Variant::List`. 
   I figured we could do something similar to the `Struct` datatype conversion 
implementation, but I can't iterate through the inner list:
   ``` rust
   DataType::List(_) => {
               let list_array = input.as_list::<i32>();
               for i in 0..list_array.len() {
                   if list_array.is_null(i) {
                       builder.append_null();
                       continue;
                   }
                   // Building a VariantList to convert it to a Variant::List
                   let mut variant_builder = VariantBuilder::new();
                   let mut list_builder = variant_builder.new_list();
   
                   for j in list_array.value(i) { // <- `std::sync::Arc<dyn 
arrow::array::Array>` is not an iterator
                       list_builder.append_value(j);
                   }
   
                   list_builder.finish();
                   
                   let (metadata, value) = variant_builder.finish();
                   let variant = Variant::new(&metadata, &value);
                   let variant_inner_list = variant.as_list();
                   let variant_list = match variant_inner_list {
                       Some(value) => Variant::List(*value),
                       None => {
                           builder.append_null();
                           continue;
                       } 
                   };
   
                   builder.append_variant(variant_list);
               }
           }
   ```


-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to