apache / apache/arrow-java

DenseUnionVector is not transferred correctly

未關閉
#200 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Type: bug
主要語言
Java
星號
94
分支
152
平均合併
3 天 16 小時
30 天內合併 PR
11

描述

### 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

貢獻指南

開啟貢獻指南

研究方向

從 java/vector/src/main/codegen/templates/DenseUnionVector.java 開始,尤其查看 TransferImpl.transfer 以及使用 nextTypeId 的迴圈。重現 Table 到 VectorSchemaRoot 的轉換,並驗證傳輸後的 DenseUnionVector 是否保留其值數量和型別狀態,以確保後續傳輸不會是空的。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
data
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
50/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。