Skip to content

ListArray equals should not consider nested values if element is marked as null #626

@jhorstmann

Description

@jhorstmann

Describe the bug

I would expect the following test case to pass. In both arrays the second element is marked as null and so they should compare equal.

#[test]
fn test_list_array_equal() {
    let mut builder = ListBuilder::new(Int64Builder::new(10));
    builder.values().append_value(1).unwrap();
    builder.values().append_value(2).unwrap();
    builder.values().append_value(3).unwrap();
    builder.append(true).unwrap();
    builder.append(false).unwrap();
    let array1 = builder.finish();

    let mut builder = ListBuilder::new(Int64Builder::new(10));
    builder.values().append_value(1).unwrap();
    builder.values().append_value(2).unwrap();
    builder.values().append_value(3).unwrap();
    builder.append(true).unwrap();
    builder.values().append_null().unwrap();
    builder.values().append_null().unwrap();
    builder.append(false).unwrap();
    let array2 = builder.finish();

    assert_eq!(array1, array2);
}

The output of the assert_eq also shows both sides the same:

assertion failed: `(left == right)`
  left: `ListArray
[
  PrimitiveArray<Int64>
[
  1,
  2,
  3,
],
  null,
]`,
 right: `ListArray
[
  PrimitiveArray<Int64>
[
  1,
  2,
  3,
],
  null,
]`

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions