InfluxCommunity / influxdb3-go

The go package that provides a simple and convenient way to interact with InfluxDB 3.
https://pkg.go.dev/github.com/InfluxCommunity/influxdb3-go
MIT License
24 stars 13 forks source link

fix: no panic if i.reader.Next() returns an empty result #37

Closed akvlad closed 1 year ago

akvlad commented 1 year ago

Proposed Changes

fix for bug if reader.Next returns an empty result. Now it results in panic:

panic: runtime error: index out of range [0] with length 0

goroutine 424 [running]:
github.com/apache/arrow/go/v12/arrow/array.(*String).Value(...)
    /go/pkg/mod/github.com/apache/arrow/go/v12@v12.0.0/arrow/array/string.go:54
github.com/InfluxCommunity/influxdb3-go/influx.getArrowValue({0x18e4ed0, 0xc000e44aa0}, 0x0)
    /go/pkg/mod/github.com/!influx!community/influxdb3-go@v0.1.0/influx/query_iterator.go:139 +0x1085
github.com/InfluxCommunity/influxdb3-go/influx.(*QueryIterator).Next(0xc000aa62c0)
    /go/pkg/mod/github.com/!influx!community/influxdb3-go@v0.1.0/influx/query_iterator.go:62 +0x205

Checklist

akvlad commented 1 year ago

This bug was reproduced when I had sent a request over about 200G of data with 5 cores.

I'll think about the way of testing it.

akvlad commented 1 year ago

Added a unit test. And optimized the fix to one line. :)