From 351ae769b353730bbde8810fb3012e2f2cb70a33 Mon Sep 17 00:00:00 2001 From: Adam Reeve Date: Tue, 16 Apr 2024 13:50:31 +1200 Subject: [PATCH] GH-41198: [C#] Fix concatenation of union arrays (#41226) ### Rationale for this change Fixes concatenation of union arrays. ### What changes are included in this PR? * Re-enables union array concatenation tests that were disabled in #41197 after making union array comparisons more thorough in the `ArrowReaderVerifier` * Updates the union array concatenation logic to account for array lengths when concatenating the type and offset buffers, and fixes how the base offset is calculated. * Fixes creating the type buffers for the array concatenation tests. ### Are these changes tested? Yes, this uses the existing `ArrowArrayConcatenatorTests` tests. ### Are there any user-facing changes? Yes, this is a user-facing bug fix. * GitHub Issue: #41198 Authored-by: Adam Reeve Signed-off-by: Curt Hagenlocher --- .../ArrowArrayConcatenatorTests.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/csharp/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs b/csharp/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs index 80c5e586963d2..bdc5051072b90 100644 --- a/csharp/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs +++ b/csharp/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs @@ -29,12 +29,6 @@ public void TestStandardCases() { foreach ((List testTargetArrayList, IArrowArray expectedArray) in GenerateTestData()) { - if (expectedArray is UnionArray) - { - // Union array concatenation is incorrect. See https://github.com/apache/arrow/issues/41198 - continue; - } - IArrowArray actualArray = ArrowArrayConcatenator.Concatenate(testTargetArrayList); ArrowReaderVerifier.CompareArrays(expectedArray, actualArray); } @@ -410,15 +404,11 @@ 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); - if (includeInResult) - { - typeResultBuilder.Append(index); - } + typeResultBuilder.Append(index); if (isDense) {