-
-
Notifications
You must be signed in to change notification settings - Fork 182
fix(#399): ARRAY column causes panic in Storage Read API Arrow serialization #496
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
lraigosov
wants to merge
3
commits into
goccy:main
Choose a base branch
from
lraigosov:feat/fix-arrow-list-builder
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.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
0903f60
fix: ARRAY column in Storage Read API causes panic in Arrow builder
lraigosov 35660fc
test: extend Arrow list builder test with nil-slice case and value as…
lraigosov ac1ee27
chore: exclude local repro directory and devlog from version control
lraigosov 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
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 |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| package types | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/apache/arrow-go/v18/arrow" | ||
| "github.com/apache/arrow-go/v18/arrow/array" | ||
| "github.com/apache/arrow-go/v18/arrow/memory" | ||
| ) | ||
|
|
||
| // TestAppendValueToARROWBuilder_List is a regression test for issue #399. | ||
| // AppendValueToARROWBuilder was calling listBuilder.Append(true) inside the | ||
| // per-element loop instead of once per row, producing N list slots instead of | ||
| // 1 and causing a row-count mismatch panic in array.RecordBuilder.NewRecord. | ||
| func TestAppendValueToARROWBuilder_List(t *testing.T) { | ||
| mem := memory.NewGoAllocator() | ||
| schema := arrow.NewSchema([]arrow.Field{ | ||
| {Name: "items", Type: arrow.ListOf(arrow.PrimitiveTypes.Int64), Nullable: true}, | ||
| }, nil) | ||
| rb := array.NewRecordBuilder(mem, schema) | ||
| defer rb.Release() | ||
|
|
||
| listBldr := rb.Field(0).(*array.ListBuilder) | ||
|
|
||
| rows := []struct { | ||
| cells []*TableCell | ||
| wantLen int | ||
| }{ | ||
| { | ||
| cells: []*TableCell{{V: "1"}, {V: "2"}, {V: "3"}}, | ||
| wantLen: 3, | ||
| }, | ||
| { | ||
| cells: []*TableCell{}, | ||
| wantLen: 0, | ||
| }, | ||
| { | ||
| cells: []*TableCell{{V: "4"}}, | ||
| wantLen: 1, | ||
| }, | ||
| { | ||
| // A nil []*TableCell is a typed nil stored in the interface V field. | ||
| // BigQuery has no null-array concept for REPEATED columns, so nil | ||
| // must behave identically to an empty slice: a valid, non-null, | ||
| // zero-length list slot. | ||
| cells: nil, | ||
| wantLen: 0, | ||
| }, | ||
| } | ||
|
|
||
| for _, row := range rows { | ||
| cell := &TableCell{V: row.cells} | ||
| if err := cell.AppendValueToARROWBuilder(listBldr); err != nil { | ||
| t.Fatalf("AppendValueToARROWBuilder: %v", err) | ||
| } | ||
| } | ||
|
|
||
| // NewRecord panics (row-count mismatch) when the bug is present. | ||
| rec := rb.NewRecord() | ||
| defer rec.Release() | ||
|
|
||
| if got := rec.NumRows(); got != int64(len(rows)) { | ||
| t.Fatalf("NumRows = %d, want %d", got, len(rows)) | ||
| } | ||
|
|
||
| col := rec.Column(0).(*array.List) | ||
| for i, row := range rows { | ||
| start, end := col.ValueOffsets(i) | ||
| if got := int(end - start); got != row.wantLen { | ||
| t.Errorf("row %d: list length = %d, want %d", i, got, row.wantLen) | ||
| } | ||
| } | ||
|
|
||
| // Verify actual element values in the first row (cells "1","2","3" → 1,2,3). | ||
| valCol := col.ListValues().(*array.Int64) | ||
| start, end := col.ValueOffsets(0) | ||
| wantVals := []int64{1, 2, 3} | ||
| if got := int(end - start); got != len(wantVals) { | ||
| t.Fatalf("row 0 element count = %d, want %d", got, len(wantVals)) | ||
| } | ||
| for i, wv := range wantVals { | ||
| if got := valCol.Value(int(start) + i); got != wv { | ||
| t.Errorf("row 0 element %d = %d, want %d", i, got, wv) | ||
| } | ||
| } | ||
| } | ||
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.
Both gaps are addressed in commit \35660fc:
Nil vs empty: Added a fourth row with \cells: nil\ (typed-nil []*TableCell\ stored in \interface{}). It asserts \wantLen: 0\ and is annotated to explain that in BigQuery REPEATED fields are always non-null — nil means empty, not null.
Element value assertions: After the per-row length loop, the test now extracts the flat \ListValues()\ array as *array.Int64\ and verifies row 0's elements are exactly [1, 2, 3]\ using \ValueOffsets\ to bound the slice.