amitvijapur commented on code in PR #11181:
URL: https://github.com/apache/arrow-rs/pull/11181#discussion_r4294743386
##########
arrow-json/src/reader/mod.rs:
##########
@@ -4381,4 +4381,68 @@ mod tests {
let err = read(false);
assert!(err.contains("returned 0 values for 1 rows"), "{err}");
}
+
+ #[test]
+ fn test_scalar_promoted_to_list() {
+ let buf = r#"{"a": 1}
Review Comment:
@alamb, Arrow C++ 19.0.0 rejects these mixed scalar/list inputs rather than
wrapping the scalar. Codex ran this through PyArrow 19.0.0, linked to Arrow C++
19.0.0:
```python
import pyarrow as pa
import pyarrow.json as pj
for data in (
b'{"foo":[1,2,3]}\n{"foo":4}\n',
b'{"foo":4}\n{"foo":[1,2,3]}\n',
):
try:
pj.read_json(pa.BufferReader(data))
except pa.ArrowInvalid as error:
print(error)
# JSON parse error: Column(/foo) changed from array to number in row 1
# JSON parse error: Column(/foo) changed from number to array in row 1
```
An explicit `foo: list<int64>` schema also rejects the scalar; list-only and
list/null controls succeed. This tests the released C++ reader through its
Python binding, not current C++ main or a separate inference API.
These results support rejecting mixed input rather than wrapping scalars, if
matching the released C++ reader is the goal. They do not establish whether
rejection belongs in Rust's standalone inference API or its reader.
@Rafferty97, I would be happy to coordinate with your existing PR once that
direction is agreed.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]