Skip to content

Commit

Permalink
fix panic on Release (#899)
Browse files Browse the repository at this point in the history
Previously if array.Concatenate returned an error not all columns
in the cols slice would be populated and would cause the deferred
function to panic on Release.

This fixes that potential panic by appending to the cols array such that
only the allocated columns are released.
  • Loading branch information
thorfour authored Jun 11, 2024
1 parent 09b1180 commit ced8217
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions query/physicalplan/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,23 +298,25 @@ func filter(pool memory.Allocator, filterExpr BooleanExpression, ar arrow.Record
totalRows += int64(r.End - r.Start)
}

cols := make([]arrow.Array, ar.NumCols())
cols := make([]arrow.Array, 0, ar.NumCols())
defer func() {
for _, col := range cols {
col.Release()
}
}()
numRanges := len(recordRanges)
for i := range cols {
for i := range ar.Columns() {
colRanges := make([]arrow.Array, 0, numRanges)
for _, rr := range recordRanges {
colRanges = append(colRanges, rr.Column(i))
}

cols[i], err = array.Concatenate(colRanges, pool)
c, err := array.Concatenate(colRanges, pool)
if err != nil {
return nil, true, err
}

cols = append(cols, c)
}

return array.NewRecord(ar.Schema(), cols, totalRows), false, nil
Expand Down

0 comments on commit ced8217

Please sign in to comment.