Skip to content

Comments

Add ListView support to arrow-row and arrow-ord#9176

Merged
alamb merged 15 commits intoapache:mainfrom
brancz:row-list-view
Jan 30, 2026
Merged

Add ListView support to arrow-row and arrow-ord#9176
alamb merged 15 commits intoapache:mainfrom
brancz:row-list-view

Conversation

@brancz
Copy link
Contributor

@brancz brancz commented Jan 14, 2026

Which issue does this PR close?

Closes #9174

What changes are included in this PR?

Implementation and tests. It's mostly copied from List.

Are these changes tested?

Yes, see unit tests.

Are there any user-facing changes?

No, purely additive.

@alamb @Jefffrey

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jan 14, 2026
Copy link
Contributor

@friendlymatthew friendlymatthew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, do you mind rebasing? I think CI is failing because this needs to be rebased on the latest master- the base branch is missing the encoded_len fn that was added recently

Otherwise, the implementation makes sense to me

@brancz brancz force-pushed the row-list-view branch 2 times, most recently from cd2a465 to 29f13ef Compare January 15, 2026 09:13
@brancz
Copy link
Contributor Author

brancz commented Jan 15, 2026

Very confused because both this PR and #9175 are based off of latest main, and the tip of the other PR seems to work fine.

@brancz
Copy link
Contributor Author

brancz commented Jan 16, 2026

Figured it out, I did actually need to change something after the rebase here, also refactored the use in both list-types.

_ => unreachable!(),
};

let null_buffer = NullBuffer::new(BooleanBuffer::new(nulls.into(), 0, rows.len()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use new_unchecked as you already have the null count and we want to avoid calculating it twice

Suggested change
let null_buffer = NullBuffer::new(BooleanBuffer::new(nulls.into(), 0, rows.len()));
let null_buffer = NullBuffer::new_unchecked(BooleanBuffer::new(nulls.into(), 0, rows.len()), null_count);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, done!


if size > 0 {
min_offset = min_offset.min(offset);
max_end = max_end.max(end);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can break if you reached maximum bounds (0 and maximum value that can be)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done (although I wonder how often this is better in practice while adding an additional branch for a case that might happen incredibly rarely)

Comment on lines 3349 to 3357
#[test]
fn test_list_view() {
test_single_list_view::<i32>();
}

#[test]
fn test_large_list_view() {
test_single_list_view::<i64>();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add nested tests like the regular list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

test_nested_list::<i64>();
}

fn test_single_list_view<O: OffsetSizeTrait>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add more tests that take advantage of the fact that this is a view, namely

  • both list point to the same value.
  • unordered offsets (one item is from offset x and some item after that is from offset y and y is before x)
  • list 1 items cover list 2 items and a little more (e.g. list 1 offset is 10 and size 5 and list 2 offset is 12 and size 2).

Copy link
Contributor Author

@brancz brancz Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done (added all cases in one test let me know if you prefer separate tests)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the list view and large list view to here as well similar to how list and large list are here.
don't forget to increase the random range so it will cover the new values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a great idea, it actually caught something

@brancz
Copy link
Contributor Author

brancz commented Jan 20, 2026

@rluvaton thoughts on the assertion vs. returning an error? I don't feel too strongly one way or another, but I do think we should be consistent for both List and ListView.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also please update the documentation here with how ListView works:

https://docs.rs/arrow-row/57.2.0/arrow_row/struct.RowConverter.html#list-encoding

It would help to review it more carefully

@brancz
Copy link
Contributor Author

brancz commented Jan 27, 2026

Added! (it's not different from Lists, but one wouldn't know that without already knowing the implementation, so I agree this was important!)

@rluvaton
Copy link
Member

@rluvaton thoughts on the assertion vs. returning an error? I don't feel too strongly one way or another, but I do think we should be consistent for both List and ListView.

consistent

@alamb alamb changed the title arrow-row: Add ListView support Add ListView support to arrow-row and arrow-ord Jan 28, 2026
@alamb alamb changed the title Add ListView support to arrow-row and arrow-ord Add ListView support to arrow-row Jan 28, 2026
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @brancz and @rluvaton and @Jefffrey -- other than the uncovered code in arrow-ord I think this PR is ready to merge.

I also reviewed this code and the test coverage, and I think it is quite good

I reviewed the code coverage here

cargo llvm-cov --html test -p arrow-row

/// └──── 2_u8 ────┘ └──── 3_u8 ────┘
///
///```
///
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

Ok(f)
}

fn compare_list_view<O: OffsetSizeTrait>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While useful, I didn't see any test coverage for this code

I think we should either break it into its own PR, or add tests. Here is a PR to do so:

(I am also happy to review a separate PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged, thank you!

I can't remember now anymore why it was, but I needed to implement compare support for something I needed for tests or fuzzing. Sorry, I've been working on so much lately that I don't remember anymore what exactly it was but it was needed to address other review comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I've been working on so much lately that I don't remember anymore what exactly it was

I TOTALLY understand

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alamb alamb changed the title Add ListView support to arrow-row Add ListView support to arrow-row and arrow-ord Jan 29, 2026
@alamb
Copy link
Contributor

alamb commented Jan 30, 2026

I merged up to resolve a conflict.

@alamb alamb merged commit 05cb6b0 into apache:main Jan 30, 2026
17 checks passed
@alamb
Copy link
Contributor

alamb commented Jan 30, 2026

Thanks again everyone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support formatting ListView

5 participants