Skip to content

Commit

Permalink
ARROW-8110: [C#] BuildArrays fails if NestedType is included
Browse files Browse the repository at this point in the history
Bug:
An ArgumentOutOfRange exception is thrown when using a NestedType column which is not at the end of RecordBatch columns.
(If RecordBatch columns have only one NestedType column and it is at the end of the columns, this exception is not thrown because this do-while loop breaks before executing GetFieldByIndex on a wrong index.)

- Use correct index number
- Change TestData in order to test this bug

Closes #6621 from HashidaTKS/ARROW-8110_fix_NestedType_serialization_bug

Authored-by: Takashi Hashida <t-hashida@amiya.co.jp>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
Takashi Hashida authored and kou committed Mar 16, 2020
1 parent 293040d commit 440f021
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions csharp/src/Apache.Arrow/Ipc/ArrowReaderImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ internal static ByteBuffer CreateByteBuffer(ReadOnlyMemory<byte> buffer)
}

var recordBatchEnumerator = new RecordBatchEnumerator(in recordBatchMessage);

var schemaFieldIndex = 0;
do
{
var field = schema.GetFieldByIndex(recordBatchEnumerator.CurrentNodeIndex);
var field = schema.GetFieldByIndex(schemaFieldIndex++);
var fieldNode = recordBatchEnumerator.CurrentNode;

var arrayData = field.DataType.IsFixedPrimitive()
Expand Down
3 changes: 1 addition & 2 deletions csharp/test/Apache.Arrow.Tests/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static RecordBatch CreateSampleRecordBatch(int length, int columnSetCount
Schema.Builder builder = new Schema.Builder();
for (int i = 0; i < columnSetCount; i++)
{
builder.Field(CreateField(new ListType(Int64Type.Default), i));
builder.Field(CreateField(BooleanType.Default, i));
builder.Field(CreateField(UInt8Type.Default, i));
builder.Field(CreateField(Int8Type.Default, i));
Expand All @@ -52,8 +53,6 @@ public static RecordBatch CreateSampleRecordBatch(int length, int columnSetCount
//builder.Field(CreateField(StringType.Default));
//builder.Field(CreateField(Time32Type.Default));
//builder.Field(CreateField(Time64Type.Default));

builder.Field(CreateField(new ListType(Int64Type.Default), i));
}

Schema schema = builder.Build();
Expand Down

0 comments on commit 440f021

Please sign in to comment.