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

Function test_struct_equal_null

arrow/tests/array_equal.rs:909–1009  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

907
908#[test]
909fn test_struct_equal_null() {
910 let strings: ArrayRef = Arc::new(StringArray::from(vec![
911 Some("joe"),
912 None,
913 None,
914 Some("mark"),
915 Some("doe"),
916 ]));
917 let ints: ArrayRef = Arc::new(Int32Array::from(vec![
918 Some(1),
919 Some(2),
920 None,
921 Some(4),
922 Some(5),
923 ]));
924 let ints_non_null: ArrayRef = Arc::new(Int32Array::from(vec![1, 2, 3, 4, 0]));
925
926 let a = ArrayData::builder(DataType::Struct(Fields::from(vec![
927 Field::new("f1", DataType::Utf8, true),
928 Field::new("f2", DataType::Int32, true),
929 ])))
930 .null_bit_buffer(Some(Buffer::from([0b00001011])))
931 .len(5)
932 .add_child_data(strings.to_data())
933 .add_child_data(ints.to_data())
934 .build()
935 .unwrap();
936 let a = make_array(a);
937
938 let b = ArrayData::builder(DataType::Struct(Fields::from(vec![
939 Field::new("f1", DataType::Utf8, true),
940 Field::new("f2", DataType::Int32, true),
941 ])))
942 .null_bit_buffer(Some(Buffer::from([0b00001011])))
943 .len(5)
944 .add_child_data(strings.to_data())
945 .add_child_data(ints_non_null.to_data())
946 .build()
947 .unwrap();
948 let b = make_array(b);
949
950 test_equal(&a, &b, true);
951
952 // test with arrays that are not equal
953 let c_ints_non_null: ArrayRef = Arc::new(Int32Array::from(vec![1, 2, 3, 0, 4]));
954 let c = ArrayData::builder(DataType::Struct(Fields::from(vec![
955 Field::new("f1", DataType::Utf8, true),
956 Field::new("f2", DataType::Int32, true),
957 ])))
958 .null_bit_buffer(Some(Buffer::from([0b00001011])))
959 .len(5)
960 .add_child_data(strings.to_data())
961 .add_child_data(c_ints_non_null.to_data())
962 .build()
963 .unwrap();
964 let c = make_array(c);
965
966 test_equal(&a, &c, false);

Callers

nothing calls this directly

Calls 7

test_equalFunction · 0.85
add_child_dataMethod · 0.80
make_arrayFunction · 0.50
buildMethod · 0.45
lenMethod · 0.45
null_bit_bufferMethod · 0.45
to_dataMethod · 0.45

Tested by

no test coverage detected