-
Notifications
You must be signed in to change notification settings - Fork 212
fix(table): validate pos delete position chunks #1337
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -391,6 +391,32 @@ func groupPosDeletesByFilePath(ctx context.Context, filePathCol, posCol *arrow.C | |
| return results, nil | ||
| } | ||
|
|
||
| func collectPosDeletePositions(positionalDeletes positionDeletes) (set[int64], error) { | ||
| deletes := set[int64]{} | ||
| for _, chunk := range positionalDeletes { | ||
| if chunk == nil { | ||
| return nil, fmt.Errorf("%w: nil pos column chunk in position delete file", | ||
| iceberg.ErrInvalidSchema) | ||
| } | ||
| if chunk.DataType().ID() != arrow.INT64 { | ||
| return nil, fmt.Errorf("%w: unsupported pos column type %s in position delete file", | ||
| iceberg.ErrInvalidSchema, chunk.DataType()) | ||
| } | ||
| for _, arr := range chunk.Chunks() { | ||
|
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 inner |
||
| posArr, ok := arr.(*array.Int64) | ||
| if !ok { | ||
| return nil, fmt.Errorf("%w: unsupported pos chunk array type %T in position delete file", | ||
| iceberg.ErrInvalidSchema, arr) | ||
| } | ||
| for _, v := range posArr.Int64Values() { | ||
| deletes[v] = struct{}{} | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return deletes, nil | ||
| } | ||
|
|
||
| func releasePosDeletes(deletes map[string]*arrow.Chunked) { | ||
| for _, chunk := range deletes { | ||
| if chunk != nil { | ||
|
|
@@ -1060,13 +1086,9 @@ func (as *arrowScan) recordsFromTask(ctx context.Context, task internal.Enumerat | |
| } | ||
|
|
||
| if applyPosDeletes { | ||
| deletes := set[int64]{} | ||
| for _, chunk := range positionalDeletes { | ||
| for _, a := range chunk.Chunks() { | ||
| for _, v := range a.(*array.Int64).Int64Values() { | ||
| deletes[v] = struct{}{} | ||
| } | ||
| } | ||
| deletes, err := collectPosDeletePositions(positionalDeletes) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| pipeline = append(pipeline, processPositionalDeletes(ctx, deletes, posSource.cursor())) | ||
|
|
@@ -1151,13 +1173,9 @@ func (as *arrowScan) producePosDeletesFromTask(ctx context.Context, task interna | |
| pipeline := make([]recProcessFn, 0, 2) | ||
| pipeline = append(pipeline, enrichRecordsWithPosDeleteFields(ctx, task.Value.File, posSource.cursor())) | ||
| if len(positionalDeletes) > 0 { | ||
| deletes := set[int64]{} | ||
| for _, chunk := range positionalDeletes { | ||
| for _, a := range chunk.Chunks() { | ||
| for _, v := range a.(*array.Int64).Int64Values() { | ||
| deletes[v] = struct{}{} | ||
| } | ||
| } | ||
| deletes, err := collectPosDeletePositions(positionalDeletes) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| pipeline = append(pipeline, processPositionalDeletes(ctx, deletes, posSource.cursor())) | ||
|
|
||
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.
Is the nil-chunk guard meant purely as defensiveness?
groupPosDeletesByFilePathonly ever stores retained, non-nil chunks into the map, so this branch shouldn't be reachable from the scan path — just want to make sure I'm not missing a caller that can pass a nil chunk in.