()
| 661 | |
| 662 | #[test] |
| 663 | fn test_create_struct_array() { |
| 664 | let size = 32; |
| 665 | let struct_fields = Fields::from(vec![ |
| 666 | Field::new("b", DataType::Boolean, true), |
| 667 | Field::new( |
| 668 | "c", |
| 669 | DataType::LargeList(Arc::new(Field::new_list_field( |
| 670 | DataType::List(Arc::new(Field::new_list_field( |
| 671 | DataType::FixedSizeBinary(6), |
| 672 | true, |
| 673 | ))), |
| 674 | false, |
| 675 | ))), |
| 676 | true, |
| 677 | ), |
| 678 | Field::new( |
| 679 | "d", |
| 680 | DataType::Struct(Fields::from(vec![ |
| 681 | Field::new("d_x", DataType::Int32, true), |
| 682 | Field::new("d_y", DataType::Float32, false), |
| 683 | Field::new("d_z", DataType::Binary, true), |
| 684 | ])), |
| 685 | true, |
| 686 | ), |
| 687 | ]); |
| 688 | let field = Field::new("struct", DataType::Struct(struct_fields), true); |
| 689 | let array = create_random_array(&field, size, 0.2, 0.5).unwrap(); |
| 690 | |
| 691 | assert_eq!(array.len(), 32); |
| 692 | let struct_array = array.as_any().downcast_ref::<StructArray>().unwrap(); |
| 693 | assert_eq!(struct_array.columns().len(), 3); |
| 694 | |
| 695 | // Test that the nested list makes sense, |
| 696 | // i.e. its children's values are more than the parent, to show repetition |
| 697 | let col_c = struct_array.column_by_name("c").unwrap(); |
| 698 | let col_c = col_c.as_any().downcast_ref::<LargeListArray>().unwrap(); |
| 699 | assert_eq!(col_c.len(), size); |
| 700 | let col_c_list = col_c.values().as_list::<i32>(); |
| 701 | assert!(col_c_list.len() > size); |
| 702 | // Its values should be FixedSizeBinary(6) |
| 703 | let fsb = col_c_list.values(); |
| 704 | assert_eq!(fsb.data_type(), &DataType::FixedSizeBinary(6)); |
| 705 | assert!(fsb.len() > col_c_list.len()); |
| 706 | |
| 707 | // Test nested struct |
| 708 | let col_d = struct_array.column_by_name("d").unwrap(); |
| 709 | let col_d = col_d.as_any().downcast_ref::<StructArray>().unwrap(); |
| 710 | let col_d_y = col_d.column_by_name("d_y").unwrap(); |
| 711 | assert_eq!(col_d_y.data_type(), &DataType::Float32); |
| 712 | assert_eq!(col_d_y.null_count(), 0); |
| 713 | } |
| 714 | |
| 715 | #[test] |
| 716 | fn test_create_run_end_encoded_array() { |
nothing calls this directly
no test coverage detected