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

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

Closed
miguelpragier opened this issue Dec 15, 2023 · 0 comments · Fixed by #39239
Closed

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

miguelpragier opened this issue Dec 15, 2023 · 0 comments · Fixed by #39239
Assignees
Milestone

Comments

@miguelpragier
Copy link
Contributor

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

zeroshade pushed a commit that referenced this issue Dec 15, 2023
…ultset (#39239)

### Rationale for this change
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 Row(s) will trigger a "Index out of Range" error.

### What changes are included in this PR?
We're preventing to include an invalid record (that can't be scanned) in an empty resultset

### Are these changes tested?
Yes, there's a new test included

### Are there any user-facing changes?
No

**This PR contains a "Critical Fix".**
* Closes: #39238

Authored-by: miguel pragier <miguel.pragier@ebnerstolz.de>
Signed-off-by: Matt Topol <zotthewizard@gmail.com>
@zeroshade zeroshade added this to the 15.0.0 milestone Dec 15, 2023
clayburn pushed a commit to clayburn/arrow that referenced this issue Jan 23, 2024
…ty resultset (apache#39239)

### Rationale for this change
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 Row(s) will trigger a "Index out of Range" error.

### What changes are included in this PR?
We're preventing to include an invalid record (that can't be scanned) in an empty resultset

### Are these changes tested?
Yes, there's a new test included

### Are there any user-facing changes?
No

**This PR contains a "Critical Fix".**
* Closes: apache#39238

Authored-by: miguel pragier <miguel.pragier@ebnerstolz.de>
Signed-off-by: Matt Topol <zotthewizard@gmail.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…ty resultset (apache#39239)

### Rationale for this change
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 Row(s) will trigger a "Index out of Range" error.

### What changes are included in this PR?
We're preventing to include an invalid record (that can't be scanned) in an empty resultset

### Are these changes tested?
Yes, there's a new test included

### Are there any user-facing changes?
No

**This PR contains a "Critical Fix".**
* Closes: apache#39238

Authored-by: miguel pragier <miguel.pragier@ebnerstolz.de>
Signed-off-by: Matt Topol <zotthewizard@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants