Skip to content
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

SNOW-880442: Add pass context to arrow fetch function #871

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading