apache / apache/arrow-java

DenseUnionVector is not transferred correctly

Abierto
#200 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Type: bug
Lenguaje dominante
Java
Estrellas
94
Forks
152
Merge medio
3 d 16 h
PR fusionados (30 d)
11

Descripción

### Describe the bug, including details regarding any error messages, version, and platform.

Hello,

I encountered a weird issue when converting a `Table` to a `VectorSchemaRoot`. All the `DenseUnionVector` were empty after the conversion.
From my understanding, it looks like there is a bug in the `TransferImpl.transfer` method of the `DenseUnionVector`.
After copying the `valueCount` value to the second vector [in this line](https://github.com/apache/arrow/blob/45918a90a6ca1cf3fd67c256a7d6a240249e555a/java/vector/src/main/codegen/templates/DenseUnionVector.java#L634), it should also set the `nextTypeId`.
After the transfer, `nextTypeId` is equals to `0`, so trying to transfer again would create an empty vector as [the for loop is done against the `nextTypeId`](https://github.com/apache/arrow/blob/45918a90a6ca1cf3fd67c256a7d6a240249e555a/java/vector/src/main/codegen/templates/DenseUnionVector.java#L628)

Proposed fix would be as simple as :

```java
@Override
public void transfer() {

...

for (int i = 0; i < nextTypeId; i++) {
if (internalTransferPairs[i] != null) {
internalTransferPairs[i].transfer();
to.childVectors[i] = internalTransferPairs[i].getTo();
}
}
to.valueCount = valueCount;
to.nextTypeId = nextTypeId;
clear();
}
```

I will raise a PR with the change.

### Component(s)

Java

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en java/vector/src/main/codegen/templates/DenseUnionVector.java, especialmente en TransferImpl.transfer y en el bucle que usa nextTypeId. Reproduce la conversión de Table a VectorSchemaRoot y verifica que un DenseUnionVector transferido conserve su cantidad de valores y su estado de tipos, de modo que una transferencia posterior no esté vacía.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
data
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
50/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.