You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "kawadakk (via GitHub)" <gi...@apache.org> on 2023/07/31 06:27:55 UTC

[GitHub] [arrow-rs] kawadakk opened a new issue, #4600: `new_null_array` generates an invalid union array

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

   **Describe the bug**
   `new_null_array` generates a union array that fails validation by `ArrayData::validate_full`.
   
   **To Reproduce**
   Modify [`test_null_union`](https://github.com/apache/arrow-rs/blob/16744e5ac08d9ead6c51ff6e08d8b91e87460c52/arrow-array/src/array/mod.rs#L819-L845) as follows: 
   ```rust
   #[test]
   fn test_null_union() {
       for mode in [UnionMode::Sparse, UnionMode::Dense] {
           let data_type = DataType::Union(
               UnionFields::new(
                   vec![2, 1],
                   vec![
                       Field::new("foo", DataType::Int32, true),
                       Field::new("bar", DataType::Int64, true),
                   ],
               ),
               mode,
           );
           let array = new_null_array(&data_type, 4);
   
           let array = as_union_array(array.as_ref());
           assert_eq!(array.len(), 4);
           assert_eq!(array.null_count(), 0);
   
           for i in 0..4 {
               let a = array.value(i);
               assert_eq!(a.len(), 1);
               assert_eq!(a.null_count(), 1);
               assert!(a.is_null(0))
           }
   
           array.to_data().validate_full().unwrap(); // <---- new
       }
   }
   ```
   
   This will fail with the following output: ``thread 'array::tests::test_null_union' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidArgumentError("Sparse union child array #1 has length smaller than expected for union array (0 < 4)")', arrow-array\src\array\mod.rs:852:45``
   
   **Expected behavior**
   Producing a valid array
   
   **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: github-unsubscribe@arrow.apache.org.apache.org

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


[GitHub] [arrow-rs] tustvold closed issue #4600: `new_null_array` generates an invalid union array

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold closed issue #4600: `new_null_array` generates an invalid union array
URL: https://github.com/apache/arrow-rs/issues/4600


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-rs] tustvold commented on issue #4600: `new_null_array` generates an invalid union array

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #4600:
URL: https://github.com/apache/arrow-rs/issues/4600#issuecomment-1678652046

   `label_issue.py` automatically added labels {'arrow'} from #4601


-- 
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-unsubscribe@arrow.apache.org

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