| 585 | |
| 586 | #[test] |
| 587 | fn scatter_dictionary_test() -> Result<()> { |
| 588 | use arrow::datatypes::Int8Type; |
| 589 | |
| 590 | let values = StringArray::from(vec!["a", "b"]); |
| 591 | let truthy = Arc::new( |
| 592 | DictionaryArray::<Int8Type>::try_new( |
| 593 | arrow::array::Int8Array::from(vec![0, 1, 0]), |
| 594 | Arc::new(values), |
| 595 | ) |
| 596 | .unwrap(), |
| 597 | ); |
| 598 | let mask = BooleanArray::from(vec![true, false, true, true, false]); |
| 599 | |
| 600 | let result = scatter(&mask, truthy.as_ref())?; |
| 601 | let result = result |
| 602 | .as_any() |
| 603 | .downcast_ref::<DictionaryArray<Int8Type>>() |
| 604 | .unwrap(); |
| 605 | |
| 606 | assert_eq!(result.len(), 5); |
| 607 | assert!(result.is_valid(0)); |
| 608 | assert!(result.is_null(1)); |
| 609 | assert!(result.is_valid(2)); |
| 610 | assert!(result.is_valid(3)); |
| 611 | assert!(result.is_null(4)); |
| 612 | Ok(()) |
| 613 | } |
| 614 | |
| 615 | #[test] |
| 616 | fn scatter_fixed_size_binary_test() -> Result<()> { |