You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "0x26res (via GitHub)" <gi...@apache.org> on 2024/05/01 09:59:37 UTC
[I] if_else bug when using chunked string array with offsets [arrow]
0x26res opened a new issue, #41479:
URL: https://github.com/apache/arrow/issues/41479
### Describe the bug, including details regarding any error messages, version, and platform.
I have a chunked array made of view/slices of the same array.
When I call if_else on that array, the results are wrong and it can results in strings that are not valid utf-8.
```python
import random
import pyarrow as pa
import pyarrow.compute as pc
sizes = [131072, 57066]
values = ['FOO', "BAR", "HELLO", "WOLRD", ""]
data = pa.array([random.choice(values) for _ in range(sum(sizes))])
inputs = pa.chunked_array(
[
data[:sizes[0]],
data[sizes[1]:]
]
)
results = pc.if_else(
pc.equal(inputs, ""),
pa.scalar(None, pa.string()),
inputs,
)
print(pc.unique(results).sort().to_pylist())
# this returns corrupted data, eg: ['\x00\x00\x00', '\x00\x00\x00\x00\x00', 'BAR', ...]
```
For context, I'm loading data from a parquet file, and replacing empty strings with nulls. This started happening when the size of the parquet file increased and data was chunked.
### Component(s)
C++, Python
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] if_else bug when using chunked string array with offsets [arrow]
Posted by "k-ishizaka (via GitHub)" <gi...@apache.org>.
k-ishizaka commented on issue #41479:
URL: https://github.com/apache/arrow/issues/41479#issuecomment-2333520096
I have encountered the same problem.
I think this problem is caused by the shortcut in if_else kernel when left is invalid.
https://github.com/apache/arrow/blob/apache-arrow-17.0.0/cpp/src/arrow/compute/kernels/scalar_if_else.cc#L740-L750
This shortcut is not safe when right is a chunk of other larger array. In this case, offset of right might starts from the middle of larger array. Because this shortcut copies value of right to value of output, offset of output should start from zero, but just a copy of right is used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org