Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Row converter does not preserve list lengths of List(Null) #7164

Open
kawadakk opened this issue Feb 20, 2025 · 0 comments
Open

Row converter does not preserve list lengths of List(Null) #7164

kawadakk opened this issue Feb 20, 2025 · 0 comments
Labels

Comments

@kawadakk
Copy link
Contributor

Describe the bug
RowConverter::convert_rows always decodes List(Null) as empty lists.

To Reproduce

let mut builder = GenericListBuilder::<O, _>::new(NullBuilder::new());
builder.values().append_nulls(0);
builder.append(true);
builder.append(false);
builder.values().append_nulls(2);
builder.append(true);

let list = Arc::new(builder.finish()) as ArrayRef;
let d = list.data_type().clone();

let converter = RowConverter::new(vec![SortField::new(d.clone())]).unwrap();

let rows = converter.convert_columns(&[Arc::clone(&list)]).unwrap();
assert!(rows.row(0) > rows.row(1)); // [null] > null
assert!(rows.row(0) < rows.row(2)); // [null] < [null, null]
assert!(rows.row(1) < rows.row(2)); // null < [null, null]

let back = converter.convert_rows(&rows).unwrap();
assert_eq!(back.len(), 1);
back[0].to_data().validate_full().unwrap();
assert_eq!(&back[0], &list);

Adding the above code to test_single_list in arrow-row/src/lib.rs causes a test failure:

thread 'tests::test_list' panicked at arrow-row/src/lib.rs:2111:9:
assertion `left == right` failed
  left: ListArray
[
  NullArray(0),
  null,
  NullArray(0),
]
 right: ListArray
[
  NullArray(0),
  null,
  NullArray(2),
]

Expected behavior
Not panicking

Additional context

@kawadakk kawadakk added the bug label Feb 20, 2025
@kawadakk kawadakk changed the title Row converter erases list lengths of List(Null) Row converter does not preserve list lengths of List(Null) Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant