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

Function test_try_new_sliced_struct

arrow/tests/array_validation.rs:943–1013  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

941
942#[test]
943fn test_try_new_sliced_struct() {
944 let mut builder = StructBuilder::new(
945 vec![
946 Field::new("a", DataType::Int32, true),
947 Field::new("b", DataType::Boolean, true),
948 ],
949 vec![
950 Box::new(Int32Builder::with_capacity(5)),
951 Box::new(BooleanBuilder::with_capacity(5)),
952 ],
953 );
954
955 // struct[0] = { a: 10, b: true }
956 builder
957 .field_builder::<Int32Builder>(0)
958 .unwrap()
959 .append_option(Some(10));
960 builder
961 .field_builder::<BooleanBuilder>(1)
962 .unwrap()
963 .append_option(Some(true));
964 builder.append(true);
965
966 // struct[1] = null
967 builder
968 .field_builder::<Int32Builder>(0)
969 .unwrap()
970 .append_option(None);
971 builder
972 .field_builder::<BooleanBuilder>(1)
973 .unwrap()
974 .append_option(None);
975 builder.append(false);
976
977 // struct[2] = { a: null, b: false }
978 builder
979 .field_builder::<Int32Builder>(0)
980 .unwrap()
981 .append_option(None);
982 builder
983 .field_builder::<BooleanBuilder>(1)
984 .unwrap()
985 .append_option(Some(false));
986 builder.append(true);
987
988 // struct[3] = { a: 21, b: null }
989 builder
990 .field_builder::<Int32Builder>(0)
991 .unwrap()
992 .append_option(Some(21));
993 builder
994 .field_builder::<BooleanBuilder>(1)
995 .unwrap()
996 .append_option(None);
997 builder.append(true);
998
999 // struct[4] = { a: 18, b: false }
1000 builder

Callers

nothing calls this directly

Calls 4

append_optionMethod · 0.45
appendMethod · 0.45
finishMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected