Skip to content

[Go] [Flightsql Driver] Empty Resultset triggers "Index out of range" error #39238

@miguelpragier

Description

@miguelpragier

Describe the bug, including details regarding any error messages, version, and platform.

Description

When having an empty resultset, the driver tries to include an empty record referece, that cannot be scanned.

So, any operation that relies on the returned *Rows will trigger a "Index out of Range" error.

We wrote a patch that prevents empty records to be appended to the resultset.

Further Details

The error is detected here, when r.currentRecord is mistankely 1, when should be zero:

At: /flight/flightsql/driver/driver.go:87

func (r *Rows) Next(dest []driver.Value) error {
	if r.currentRecord >= len(r.records) {
		return io.EOF
	}
	record := r.records[r.currentRecord]

	if int64(r.currentRow) >= record.NumRows() { // IS TRIGGERED HERE
		return ErrOutOfRange
	}

But happens here:

At: /flight/flightsql/driver/driver.go:492

	for reader.Next() {
		record := reader.Record()
		record.Retain()
		records = append(records, record) // BUT HAPPENS HERE
	}

Platform, Arrow/Flight & Go

OS: Linux
Arrow Driver: github.com/apache/arrow/go/v14/arrow/flight/flightsql/driver
Go Version: go1.21.4 linux/amd64

Component(s)

Go

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions