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

feat: make FixedSizeList scalar also an ArrayRef #8221

Merged
merged 1 commit into from
Nov 16, 2023
Merged

Conversation

wjones127
Copy link
Member

Which issue does this PR close?

Changes ScalarValue::FixedSizeList() to wrap an ArrayRef. This is an API breaking change, so while I did this I also fixed the capitalization of the name Fixedsizelist to FixedSizeList, 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?

  • Rename ScalarValue::Fixedsizelist to ScalarValue::FixedSizeList.
  • Change 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.

@wjones127 wjones127 added enhancement New feature or request datafusion Changes in the datafusion crate api change Changes the API exposed to users of the crate labels Nov 15, 2023
@github-actions github-actions bot added the optimizer Optimizer rules label Nov 15, 2023
@wjones127 wjones127 changed the title feat: make FSL scalar also an arrayref feat: make FixedSizeList scalar also an ArrayRef Nov 15, 2023
@wjones127 wjones127 marked this pull request as ready for review November 15, 2023 20:53
@wjones127
Copy link
Member Author

cc @jayzhan211

Copy link
Contributor

@jayzhan211 jayzhan211 left a 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
Copy link
Contributor

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

Copy link
Member Author

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.

@jayzhan211
Copy link
Contributor

Should we keep length for FixedSizeList? Like FixedSizeList(ArrayRef, i32)

I think we dont need, we just assume we have FixedSizeList as ArrayRef

Copy link
Contributor

@comphead comphead left a 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 👍

@wjones127 wjones127 merged commit b013087 into main Nov 16, 2023
44 checks passed
@wjones127 wjones127 deleted the fsl-scalar-arrayref branch November 16, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change Changes the API exposed to users of the crate datafusion Changes in the datafusion crate enhancement New feature or request optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change FixedSizeList Scalar to use array
4 participants