kawadakk opened a new issue, #7169:
URL: https://github.com/apache/arrow-rs/issues/7169

   **Describe the bug**
   `RowConverter::convert_rows` flattens all dictionary arrays, but the 
`data_type` of the returned array still contain `Dictionary`.
   
   **To Reproduce**
   ```rust
   #[test]
   fn test_dictionary_in_struct() {
       let ty = DataType::Struct(
           vec![Field::new_dictionary(
               "foo",
               DataType::Int32,
               DataType::Int32,
               false,
           )]
           .into(),
       );
       let s = arrow_array::new_empty_array(&ty);
   
       let sort_fields = vec![SortField::new(s.data_type().clone())];
       let converter = RowConverter::new(sort_fields).unwrap();
       let r = converter.convert_columns(&[Arc::clone(&s)]).unwrap();
   
       let back = converter.convert_rows(&r).unwrap();
       let [s2] = back.try_into().unwrap();
       assert_eq!(&s2, &s);
   
       println!("s2 = {s2:?}, s2.ty = {}", s2.data_type());
   
       s2.to_data().validate_full().unwrap();
   }
   ```
   
   ```
   s2 = StructArray
   -- validity: 
   [
   ]
   [
   -- child 0: "foo" (Int32)
   PrimitiveArray<Int32>
   [
   ]
   ], s2.ty = Struct([Field { name: "foo", data_type: Dictionary(Int32, Int32), 
nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }])
   thread 'tests::test_dictionary_in_struct' panicked at 
arrow-row/src/lib.rs:1884:38:
   called `Result::unwrap()` on an `Err` value: InvalidArgumentError("Child 
type mismatch for Struct([Field { name: \"foo\", data_type: Dictionary(Int32, 
Int32), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }]). 
Expected Dictionary(Int32, Int32) but child data had Int32")
   ```
   
   **Expected behavior**
   - The decoded array passes validation
   - One of the following is true:
       - The first child of `s2` is `DictionaryArray`, and the first subfield 
of `s2.data_type()` is `Dictionary(_, Int32)`.
       - The first child of `s2` is `Int32Array`, and the first subfield of 
`s2.data_type()` is `Int32`.
   
   
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->


-- 
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