Skip to content

Commit

Permalink
Nil pointer access due to empty chunk returned from gosnowflake.build…
Browse files Browse the repository at this point in the history
…FirstArrowChunk

Modify gosnowflake.buildFirstArrowChunk to return an error and pass it
back up the call stack.

The following three tests fail additionally compared to upstream, which
is expected (see 'Maintaining the gosnowflake fork'):

> TestPutGetFile
> TestPutGetStream
> TestPutGetGcsDownscopedCredential
  • Loading branch information
Till Kolditz committed Dec 5, 2023
1 parent 8e96b82 commit 177b067
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions arrow_chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ func (arc *arrowResultChunk) decodeArrowBatch(scd *snowflakeChunkDownloader) (*[
}

// Build arrow chunk based on RowSet of base64
func buildFirstArrowChunk(rowsetBase64 string, loc *time.Location, alloc memory.Allocator) arrowResultChunk {
func buildFirstArrowChunk(rowsetBase64 string, loc *time.Location, alloc memory.Allocator) (arrowResultChunk, error) {
rowSetBytes, err := base64.StdEncoding.DecodeString(rowsetBase64)
if err != nil {
return arrowResultChunk{}
return arrowResultChunk{}, err
}
rr, err := ipc.NewReader(bytes.NewReader(rowSetBytes), ipc.WithAllocator(alloc))
if err != nil {
return arrowResultChunk{}
return arrowResultChunk{}, err
}

return arrowResultChunk{rr, 0, loc, alloc}
return arrowResultChunk{rr, 0, loc, alloc}, nil
}
10 changes: 8 additions & 2 deletions chunk_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ func (scd *snowflakeChunkDownloader) start() error {
if scd.sc != nil && scd.sc.cfg != nil {
loc = getCurrentLocation(scd.sc.cfg.Params)
}
firstArrowChunk := buildFirstArrowChunk(scd.RowSet.RowSetBase64, loc, scd.pool)
firstArrowChunk, err := buildFirstArrowChunk(scd.RowSet.RowSetBase64, loc, scd.pool)
if err != nil {
return err
}
higherPrecision := higherPrecisionEnabled(scd.ctx)
scd.CurrentChunk, err = firstArrowChunk.decodeArrowChunk(scd.RowSet.RowType, higherPrecision)
scd.CurrentChunkSize = firstArrowChunk.rowCount
Expand Down Expand Up @@ -274,7 +277,10 @@ func (scd *snowflakeChunkDownloader) startArrowBatches() error {
if scd.sc != nil && scd.sc.cfg != nil {
loc = getCurrentLocation(scd.sc.cfg.Params)
}
firstArrowChunk := buildFirstArrowChunk(scd.RowSet.RowSetBase64, loc, scd.pool)
firstArrowChunk, err := buildFirstArrowChunk(scd.RowSet.RowSetBase64, loc, scd.pool)
if err != nil {
return err
}
scd.FirstBatch = &ArrowBatch{
idx: 0,
scd: scd,
Expand Down

0 comments on commit 177b067

Please sign in to comment.