[C#] csharp/src/Apache.Arrow/Ipc/ArrowReaderImplementation: Out of range exception when schema.GetFieldByIndex is called
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
In some scenarios, the loop moves past the length of the schema index, causing an out of range exception when `schema.GetFieldByIndex` is called. In particular, this was observed when calling:
```
ArrowFileReader reader = new ArrowFileReader(fs))
int batches = reader.RecordBatchCountAsync().Result; // does not get the error on this call, even though the same BuildArrays call is made
for (int i = 0; i < batches; i++)
{
RecordBatch recordBatch = reader.ReadNextRecordBatch();
// ...
}
```
The error occurs on the first call to `ReadNextRecordBatch`
The specific stack trace is:
```
Stack Trace:
List`1.get_Item(Int32 index)
Schema.GetFieldByIndex(Int32 i) line 71
ArrowReaderImplementation.BuildArrays(MetadataVersion version, Schema schema, ByteBuffer messageBuffer, RecordBatch recordBatchMessage) line 191
ArrowReaderImplementation.CreateArrowObjectFromMessage(Message message, ByteBuffer bodyByteBuffer, IMemoryOwner`1 memoryOwner) line 123
ArrowStreamReaderImplementation.ReadMessage() line 143
ArrowStreamReaderImplementation.ReadRecordBatch() line 111
ArrowFileReaderImplementation.ReadRecordBatch(Int32 index) line 176
ArrowFileReaderImplementation.ReadNextRecordBatch() line 205
ArrowStreamReader.ReadNextRecordBatch() line 107
ReplayableUtils.LoadRecordBatches(String location) line 79
ReplayableStatement.ExecuteQuery() line 62
DriverTests.CanRun() line 67
```
### Component(s)
C#
Contributor guide
Assessment
This issue has not been assessed yet.