Skip to content

Commit

Permalink
apacheGH-41164: [C#] Fix concatenation of sliced arrays (apache#41245)
Browse files Browse the repository at this point in the history
### Rationale for this change

Makes array concatenation work correctly when the input arrays have been sliced.

### What changes are included in this PR?

* Updates the array concatenation tests so that the `TestDataGenerator` can generate test cases with sliced input arrays. To avoid too much duplicated logic, I've added a new `GenerateTestData<TArray, TArrayBuilder>` method that works with builders that are not `IArrowArrayBuilder<T, TArray, TArrayBuilder>`, and simplified a lot of the data generation by using this new method. Only struct and union array test data generation still needs to duplicate the logic in `GenerateTestData`.
* Fixes `ArrayDataConcatenator` logic to handle sliced input arrays

### Are these changes tested?

Yes, I've added a new test for this.

### Are there any user-facing changes?

Yes, this is a user-facing bug fix.
* GitHub Issue: apache#41164

Authored-by: Adam Reeve <adreeve@gmail.com>
Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
  • Loading branch information
adamreeve authored and rok committed May 8, 2024
1 parent edc170e commit 97cea96
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,15 @@ public void Visit(UnionType type)

for (int j = 0; j < dataList.Count; j++)
{
bool includeInResult = IncludeInResult(i, j);
byte index = (byte)Math.Min(j % 3, 1);
int? intValue = (index == 1) ? dataList[j] : null;
string stringValue = (index == 1) ? null : dataList[j]?.ToString();
typeBuilder.Append(index);
typeResultBuilder.Append(index);
if (includeInResult)
{
typeResultBuilder.Append(index);
}

if (isDense)
{
Expand Down

0 comments on commit 97cea96

Please sign in to comment.