Repository navigation
GH-54570: [C++][Compute] Fix segfault casting null list with empty child to fixed_size_list #54574
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
Open
ShivanshhhG
wants to merge
1
commit into
apache:main
Choose a base branch
from
ShivanshhhG:fix-54570-cast-null-list-to-fixed-size-list
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+87
−14
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3787,6 +3787,72 @@ TEST(Cast, ListToFSL) { | |
| // Invalid fixed_size_list cast if inconsistent size | ||
| ASSERT_RAISES(Invalid, Cast(ArrayFromJSON(list(int32()), "[[0, 1, 2], null, [3, 4]]"), | ||
| CastOptions::Safe(fixed_size_list(int32(), 3)))); | ||
|
|
||
| // GH-54570: Null list array with empty child array cast to FixedSizeList | ||
| { | ||
| auto child = ArrayFromJSON(int64(), "[]"); | ||
| ASSERT_OK_AND_ASSIGN( | ||
| auto from, | ||
| ListArray::FromArrays(*ArrayFromJSON(int32(), "[0, 0]"), *child, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The C++ build has not run yet however compiling this locally reports an error because the third argument to FromArrays expects MemoryPool*, but receives an Array. Did you compile/run this before submitting? |
||
| *ArrayFromJSON(boolean(), "[false]"))); | ||
| auto to = ArrayFromJSON(fixed_size_list(int64(), 3), "[null]"); | ||
| CheckCast(from, to); | ||
| } | ||
|
|
||
| // GH-54570: LargeList with empty child cast to FixedSizeList | ||
| { | ||
| auto child = ArrayFromJSON(int64(), "[]"); | ||
| ASSERT_OK_AND_ASSIGN( | ||
| auto from, | ||
| LargeListArray::FromArrays(*ArrayFromJSON(int64(), "[0, 0]"), *child, | ||
| *ArrayFromJSON(boolean(), "[false]"))); | ||
| auto to = ArrayFromJSON(fixed_size_list(int64(), 3), "[null]"); | ||
| CheckCast(from, to); | ||
| } | ||
|
|
||
| // GH-54570: Multiple null lists with empty child | ||
| { | ||
| auto child = ArrayFromJSON(int64(), "[]"); | ||
| ASSERT_OK_AND_ASSIGN( | ||
| auto from, | ||
| ListArray::FromArrays(*ArrayFromJSON(int32(), "[0, 0, 0]"), *child, | ||
| *ArrayFromJSON(boolean(), "[false, false]"))); | ||
| auto to = ArrayFromJSON(fixed_size_list(int64(), 2), "[null, null]"); | ||
| CheckCast(from, to); | ||
| } | ||
|
|
||
| // GH-54570: Null list with unallocated/null child data buffers | ||
| { | ||
| auto child_data = ArrayData::Make(int64(), 0, {nullptr, nullptr}); | ||
| auto list_bitmap = ArrayFromJSON(boolean(), "[false]")->data()->buffers[1]; | ||
| auto list_offsets = ArrayFromJSON(int32(), "[0, 0]")->data()->buffers[1]; | ||
| auto list_data = ArrayData::Make(list(int64()), 1, {list_bitmap, list_offsets}, | ||
| {child_data}, 1); | ||
| auto from = MakeArray(list_data); | ||
| auto to = ArrayFromJSON(fixed_size_list(int64(), 3), "[null]"); | ||
| CheckCast(from, to); | ||
| } | ||
|
|
||
| // GH-54570: Null slots with length 0 alongside valid slots | ||
| { | ||
| auto child = ArrayFromJSON(int32(), "[10, 20]"); | ||
| ASSERT_OK_AND_ASSIGN( | ||
| auto from, | ||
| ListArray::FromArrays(*ArrayFromJSON(int32(), "[0, 0, 2]"), *child, | ||
| *ArrayFromJSON(boolean(), "[false, true]"))); | ||
| auto to = ArrayFromJSON(fixed_size_list(int32(), 2), "[null, [10, 20]]"); | ||
| CheckCast(from, to); | ||
| } | ||
|
|
||
| { | ||
| auto child = ArrayFromJSON(int32(), "[10, 20]"); | ||
| ASSERT_OK_AND_ASSIGN( | ||
| auto from, | ||
| ListArray::FromArrays(*ArrayFromJSON(int32(), "[0, 2, 2]"), *child, | ||
| *ArrayFromJSON(boolean(), "[true, false]"))); | ||
| auto to = ArrayFromJSON(fixed_size_list(int32(), 2), "[[10, 20], null]"); | ||
| CheckCast(from, to); | ||
| } | ||
| } | ||
|
|
||
| TEST(Cast, CastMap) { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The list-view inputs mentioned in the description still fail before reaching this branch. ValidateLengths reads offsets[length], but list views have only length offsets and a separate sizes buffer.
Please add regression tests for all-null ListView and LargeListView inputs with empty children. Either handle these layouts here or narrow the claimed scope and track the remaining bug separately.