rok commented on code in PR #44070:
URL: https://github.com/apache/arrow/pull/44070#discussion_r1756573249
##########
python/pyarrow/tests/test_extension_type.py:
##########
@@ -1926,3 +1926,31 @@ def test_bool8_scalar():
assert pa.scalar(1, type=pa.bool8()).as_py() is True
assert pa.scalar(2, type=pa.bool8()).as_py() is True
assert pa.scalar(None, type=pa.bool8()).as_py() is None
+
+
[email protected]("str_type", (pa.utf8, pa.large_utf8))
+def test_json(str_type):
+ storage_type = str_type()
+ data = ['{"a": 1}', '{"b": 2}', None]
+ storage = pa.array(data, type=storage_type)
+ json_type = pa.json(storage_type)
+
+ assert json_type.extension_name == "arrow.json"
+ assert json_type.storage_type == storage_type
+ assert json_type.__class__ is pa.JsonType
+
+ array = pa.ExtensionArray.from_storage(json_type, storage)
+
+ assert array.to_pylist() == data
+ assert array[0].as_py() == data[0]
+ assert array[2].as_py() is None
+
+ buf = ipc_write_batch(pa.RecordBatch.from_arrays([array], ["json"]))
Review Comment:
Added pickle and cast tests. Cast test fails for
`extenstion.cast(string_view)`. I've not checked why yet but probably we're
missing a cast kernel for view types?
```python
pyarrow.lib.ArrowNotImplementedError: Unsupported cast to string_view from
extension<arrow.json>
```
--
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]