MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_create_map_array

Function test_create_map_array

arrow/src/util/data_gen.rs:819–844  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

817
818 #[test]
819 fn test_create_map_array() {
820 let map_field = Field::new_map(
821 "map",
822 "entries",
823 Field::new("key", DataType::Utf8, false),
824 Field::new("value", DataType::Utf8, true),
825 false,
826 false,
827 );
828 let array = create_random_array(&map_field, 100, 0.8, 0.5).unwrap();
829
830 assert_eq!(array.len(), 100);
831 // Map field is not null
832 assert_eq!(array.null_count(), 0);
833 assert_eq!(array.logical_null_count(), 0);
834 // Maps have multiple values like a list, so internal arrays are longer
835 assert!(array.as_map().keys().len() > array.len());
836 assert!(array.as_map().values().len() > array.len());
837 // Keys are not nullable
838 assert_eq!(array.as_map().keys().null_count(), 0);
839 // Values are nullable
840 assert!(array.as_map().values().null_count() > 0);
841
842 assert_eq!(array.as_map().keys().data_type(), &DataType::Utf8);
843 assert_eq!(array.as_map().values().data_type(), &DataType::Utf8);
844 }
845
846 #[test]
847 fn test_create_decimal_array() {

Callers

nothing calls this directly

Calls 1

create_random_arrayFunction · 0.85

Tested by

no test coverage detected