Skip to content

Commit

Permalink
GH-43320: [Java] fix for SchemaChangeRuntimeException transferring em…
Browse files Browse the repository at this point in the history
…pty 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]>
  • Loading branch information
jarohen authored Jul 19, 2024
1 parent 0bae073 commit bbfb7b9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ public TransferImpl(Field field, BufferAllocator allocator, CallBack callBack) {

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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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;
Expand Down Expand Up @@ -243,6 +244,34 @@ public void testTransferPair() {
}
}

@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 =
Expand Down

0 comments on commit bbfb7b9

Please sign in to comment.