This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new bbfb7b964f GH-43320: [Java] fix for SchemaChangeRuntimeException 
transferring empty FixedSizeListVector (#43321)
bbfb7b964f is described below

commit bbfb7b964fd6e0a0675b444cf50a96e41177c314
Author: James Henderson <[email protected]>
AuthorDate: Fri Jul 19 02:52:34 2024 +0100

    GH-43320: [Java] fix for SchemaChangeRuntimeException transferring empty 
FixedSizeListVector (#43321)
    
    ### What changes are included in this PR?
    
    When we create a FSLV through TransferImpl, we check to see if the source's 
element vector is a ZeroVector and, if not, we don't call addOrGetVector.
    
    ### Are these changes tested?
    
    Yep - see TestFixedSizeListVector
    
    ### Are there any user-facing changes?
    
    No
    * GitHub Issue: #43320
    
    Authored-by: James Henderson <[email protected]>
    Signed-off-by: David Li <[email protected]>
---
 .../arrow/vector/complex/FixedSizeListVector.java  |  4 ++-
 .../arrow/vector/TestFixedSizeListVector.java      | 29 ++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git 
a/java/vector/src/main/java/org/apache/arrow/vector/complex/FixedSizeListVector.java
 
b/java/vector/src/main/java/org/apache/arrow/vector/complex/FixedSizeListVector.java
index 7a88eaf162..cb45508480 100644
--- 
a/java/vector/src/main/java/org/apache/arrow/vector/complex/FixedSizeListVector.java
+++ 
b/java/vector/src/main/java/org/apache/arrow/vector/complex/FixedSizeListVector.java
@@ -602,7 +602,9 @@ public class FixedSizeListVector extends BaseValueVector
 
     public TransferImpl(FixedSizeListVector to) {
       this.to = to;
-      to.addOrGetVector(vector.getField().getFieldType());
+      if (!(vector instanceof ZeroVector)) {
+        to.addOrGetVector(vector.getField().getFieldType());
+      }
       dataPair = vector.makeTransferPair(to.vector);
     }
 
diff --git 
a/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java
 
b/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java
index fc220e0f05..f582406de6 100644
--- 
a/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java
+++ 
b/java/vector/src/test/java/org/apache/arrow/vector/TestFixedSizeListVector.java
@@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import java.math.BigDecimal;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import org.apache.arrow.memory.BufferAllocator;
@@ -243,6 +244,34 @@ public class TestFixedSizeListVector {
     }
   }
 
+  @Test
+  public void testTransferEmptyVector() throws Exception {
+    // #43320
+    try (FixedSizeListVector src =
+            new FixedSizeListVector(
+                "src", allocator, FieldType.nullable(new 
ArrowType.FixedSizeList(2)), null);
+        FixedSizeListVector dest =
+            new FixedSizeListVector(
+                "dest", allocator, FieldType.nullable(new 
ArrowType.FixedSizeList(2)), null)) {
+      src.makeTransferPair(dest).transfer();
+
+      IntVector els =
+          (IntVector) 
dest.addOrGetVector(FieldType.nullable(MinorType.INT.getType())).getVector();
+
+      dest.allocateNew();
+      dest.startNewValue(0);
+      els.setSafe(0, 1);
+      els.setSafe(1, 2);
+      dest.setValueCount(1);
+
+      List<Integer> expected = new ArrayList<>(2);
+      expected.add(1);
+      expected.add(2);
+
+      assertEquals(expected, dest.getObject(0));
+    }
+  }
+
   @Test
   public void testConsistentChildName() throws Exception {
     try (FixedSizeListVector listVector =

Reply via email to