From fec38ba82d2abe65a0320733e49efe7ec989f636 Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Mon, 17 Jul 2023 15:52:39 -0400 Subject: [PATCH] fix(arrow): handle non-arrow result sets (#851) --- connection.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/connection.go b/connection.go index 3fa9cd4e5..aa26e8532 100644 --- a/connection.go +++ b/connection.go @@ -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 { @@ -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.