-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: make FixedSizeList scalar also an ArrayRef #8221
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
cc @jayzhan211 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep length for FixedSizeList? Like FixedSizeList(ArrayRef, i32)
@@ -1032,8 +1020,11 @@ impl ScalarValue { | |||
ScalarValue::Binary(v) => v.is_none(), | |||
ScalarValue::FixedSizeBinary(_, v) => v.is_none(), | |||
ScalarValue::LargeBinary(v) => v.is_none(), | |||
ScalarValue::Fixedsizelist(v, ..) => v.is_none(), | |||
ScalarValue::List(arr) => arr.len() == arr.null_count(), | |||
// arr.len() should be 1 for a list scalar, but we don't seem to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why arr.len()
should be 1? I thought it can be any kind of ListArray
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If arr.len() > 1
, it isn't a scalar. arr
is a ListArray
or FixedSizeListArray
, so arr.len() == 1
means there is one list.
I think we dont need, we just assume we have FixedSizeList as ArrayRef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @wjones127, that sounds like a nice change 👍
Which issue does this PR close?
Changes
ScalarValue::FixedSizeList()
to wrap anArrayRef
. This is an API breaking change, so while I did this I also fixed the capitalization of the nameFixedsizelist
toFixedSizeList
, so it's consistent with the data and array type in arrow-rs.Closes #8218.
Rationale for this change
We can re-use a lot of functions with
ScalarValue::List
, and this representation leaves less room for invalid state (for example, previously one could create a scalar that contained scalar values of varying data type).What changes are included in this PR?
ScalarValue::Fixedsizelist
toScalarValue::FixedSizeList
.ScalarValue::FixedSizeList
to wrap an array ref.Are these changes tested?
There's not much testing for this type. I can work on adding more tests in #8220.
Are there any user-facing changes?
Yes, this is a breaking API change.