You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "westonpace (via GitHub)" <gi...@apache.org> on 2025/04/02 22:02:24 UTC
Re: [I] StructArray from ArrayData Ignores Offset [arrow-rs]
westonpace commented on issue #6151:
URL: https://github.com/apache/arrow-rs/issues/6151#issuecomment-2773833480
Here's a small datafusion-python example showing the potential dangers in an end-to-end environment:
```
import pyarrow as pa
from datafusion import SessionContext
ctx = SessionContext()
batch = pa.table({"s": [{"x": 7}, {"x": 7}, None, {"x": None}, {"x": 7}] }).to_batches()[0]
sliced = batch.slice(1, 3)
print(ctx.create_dataframe([[sliced]]).show())
hand_sliced = pa.table({"s": [{"x": 7}, None, {"x": None}] }).to_batches()[0]
print(ctx.create_dataframe([[hand_sliced]]).show())
assert sliced == hand_sliced
```
Output:
```
DataFrame()
+--------+
| s |
+--------+
| {x: 7} |
| |
| {x: 0} |
+--------+
None
DataFrame()
+--------+
| s |
+--------+
| {x: 7} |
| |
| {x: } |
+--------+
None
```
The validity of the inner array is incorrect because the offset is lost and so we silently get `{x: 0}` instead of `{x: null}`.
--
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