Skip to content

Support ListView in length kernel#9346

Merged
Jefffrey merged 1 commit intoapache:mainfrom
vegarsti:list-view-length
Feb 5, 2026
Merged

Support ListView in length kernel#9346
Jefffrey merged 1 commit intoapache:mainfrom
vegarsti:list-view-length

Conversation

@vegarsti
Copy link
Copy Markdown
Contributor

@vegarsti vegarsti commented Feb 3, 2026

Which issue does this PR close?

Closes #9343.

Are these changes tested?

Yes, added tests

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Feb 3, 2026
Copy link
Copy Markdown
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

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

Nice and simple 👍

Copy link
Copy Markdown
Contributor

@codephage2020 codephage2020 left a comment

Choose a reason for hiding this comment

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

The PR is good as-is for the length kernel. However, consider also adding bit_length support in a follow-up or in this same PR:

DataType::ListView(_) => {
    let list = array.as_list_view::<i32>();
    let v: Vec<i32> = list.sizes().iter().map(|s| s.wrapping_mul(8)).collect();
    Ok(Arc::new(Int32Array::new(v.into(), list.nulls().cloned())))
}
DataType::LargeListView(_) => {
    let list = array.as_list_view::<i64>();
    let v: Vec<i64> = list.sizes().iter().map(|s| s.wrapping_mul(8)).collect();
    Ok(Arc::new(Int64Array::new(v.into(), list.nulls().cloned())))
}

Comment thread arrow-string/src/length.rs Outdated
Comment thread arrow-string/src/length.rs Outdated
@vegarsti
Copy link
Copy Markdown
Contributor Author

vegarsti commented Feb 3, 2026

Nice one @codephage2020! Can do that here. Thanks for providing the code!

@Jefffrey
Copy link
Copy Markdown
Contributor

Jefffrey commented Feb 3, 2026

Actually, I don't think it makes sense to support list types in bit_length 🤔

I know we have existing support for regular List/LargeList, but this seems to be introduced in error by #4718 as far as I can tell. It doesn't make sense to compute bit length of lists based on the assumption that each element of the list = 1 byte.

@vegarsti
Copy link
Copy Markdown
Contributor Author

vegarsti commented Feb 3, 2026

Actually, I don't think it makes sense to support list types in bit_length 🤔

I know we have existing support for regular List/LargeList, but this seems to be introduced in error by #4718 as far as I can tell. It doesn't make sense to compute bit length of lists based on the assumption that each element of the list = 1 byte.

Oh I see. Thanks. I'll remove it then.

@vegarsti
Copy link
Copy Markdown
Contributor Author

vegarsti commented Feb 3, 2026

Done!

@codephage2020
Copy link
Copy Markdown
Contributor

Actually, I don't think it makes sense to support list types in bit_length 🤔
I know we have existing support for regular List/LargeList, but this seems to be introduced in error by #4718 as far as I can tell. It doesn't make sense to compute bit length of lists based on the assumption that each element of the list = 1 byte.

@Jefffrey Exactly. After reviewing the code, bit_length for List/LargeList multiplies element count by 8, which is semantically wrong since elements can be arbitrary types.

Oh I see. Thanks. I'll remove it then.

@vegarsti Could you also remove the existing List/LargeList support for bit_length?

@Jefffrey
Copy link
Copy Markdown
Contributor

Jefffrey commented Feb 4, 2026

I've raised a separate issue for removing the existing implementation:

I think it would be better to leave this PR as improving support for ListViews only, and have a separate PR for a potentially behavioural change

@vegarsti
Copy link
Copy Markdown
Contributor Author

vegarsti commented Feb 4, 2026

To clarify, you still approve this @Jefffrey? 🙏🏻

@Jefffrey
Copy link
Copy Markdown
Contributor

Jefffrey commented Feb 4, 2026

Yes

@Jefffrey Jefffrey merged commit 8d8e558 into apache:main Feb 5, 2026
18 checks passed
@Jefffrey
Copy link
Copy Markdown
Contributor

Jefffrey commented Feb 5, 2026

Thanks @vegarsti & @codephage2020

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 ListView in length kernel

3 participants