Skip to content

Commit

Permalink
SNOW-880442: Add pass context to arrow fetch function
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pfus committed Aug 2, 2023
1 parent 46bdc88 commit 6eefb97
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion chunk_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,13 @@ type ArrowBatch struct {
rowCount int
scd *snowflakeChunkDownloader
funcDownloadHelper func(context.Context, *snowflakeChunkDownloader, int) error
ctx context.Context
}

// WithContext sets the context which will be used for this ArrowBatch.
func (rb *ArrowBatch) WithContext(ctx context.Context) *ArrowBatch {
rb.ctx = ctx
return rb
}

// Fetch returns an array of records representing a chunk in the query
Expand All @@ -717,7 +724,13 @@ func (rb *ArrowBatch) Fetch() (*[]arrow.Record, error) {
rb.rowCount = countArrowBatchRows(rb.rec)
return rb.rec, nil
}
if err := rb.funcDownloadHelper(context.Background(), rb.scd, rb.idx); err != nil {
var ctx context.Context
if rb.ctx != nil {
ctx = rb.ctx
} else {
ctx = context.Background()
}
if err := rb.funcDownloadHelper(ctx, rb.scd, rb.idx); err != nil {
return nil, err
}
return rb.rec, nil
Expand Down

0 comments on commit 6eefb97

Please sign in to comment.