Skip to content

Commit

Permalink
fix(arrow): handle non-arrow result sets (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroshade committed Jul 17, 2023
1 parent 3623a16 commit fec38ba
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,18 @@ func (asb *ArrowStreamBatch) GetStream(ctx context.Context) (io.ReadCloser, erro

// ArrowStreamLoader is a convenience interface for downloading
// Snowflake results via multiple Arrow Record Batch streams.
//
// Some queries from Snowflake do not return Arrow data regardless
// of the settings, such as "SHOW WAREHOUSES". In these cases,
// you'll find TotalRows() > 0 but GetBatches returns no batches
// and no errors. In this case, the data is accessible via JSONData
// with the actual types matching up to the metadata in RowTypes.
type ArrowStreamLoader interface {
GetBatches() ([]ArrowStreamBatch, error)
TotalRows() int64
RowTypes() []execResponseRowType
Location() *time.Location
JSONData() [][]*string
}

type snowflakeArrowStreamChunkDownloader struct {
Expand All @@ -605,6 +612,9 @@ func (scd *snowflakeArrowStreamChunkDownloader) TotalRows() int64 { return scd.T
func (scd *snowflakeArrowStreamChunkDownloader) RowTypes() []execResponseRowType {
return scd.RowSet.RowType
}
func (scd *snowflakeArrowStreamChunkDownloader) JSONData() [][]*string {
return scd.RowSet.JSON
}

// the server might have had an empty first batch, check if we can decode
// that first batch, if not we skip it.
Expand Down

0 comments on commit fec38ba

Please sign in to comment.