aad1tyaaaaa opened a new issue, #1040:
URL: https://github.com/apache/arrow-nanoarrow/issues/1040

   The C library has `NANOARROW_TYPE_DECIMAL32` and `NANOARROW_TYPE_DECIMAL64`, 
but the Python bindings don't expose them, so these arrays can't be iterated 
and the types can't be created from Python:
   
   ```python
   import pyarrow as pa
   from decimal import Decimal
   from nanoarrow.iterator import iter_py
   
   list(iter_py(pa.array([Decimal("1.5"), None], pa.decimal32(5, 1))))
   # KeyError: "Can't resolve iterator for type 'decimal32'"
   list(iter_py(pa.array([Decimal("-1.250")], pa.decimal64(18, 3))))
   # KeyError: "Can't resolve iterator for type 'decimal64'"
   ```
   
   There is also no `na.decimal32()` / `na.decimal64()` or `na.Type.DECIMAL32` 
/ `DECIMAL64`. (Found while comparing `iter_py()` with pyarrow's `to_pylist()` 
across types on `main`; apart from these and `list_view` / `run_end_encoded`, 
which also have no iterator, every type I tried matched.)
   
   Would you take a PR adding them to the Python bindings? Roughly, following 
how `DECIMAL128` / `DECIMAL256` are handled:
   
   - `_types.pxd` / `_types.pyx` / `_types.pyi`: the two type ids, 
`is_decimal()`, and the struct format sizes (`"4s"`, `"8s"`) in the buffer 
format mapping
   - `schema.py`: `Type.DECIMAL32` / `Type.DECIMAL64`, `decimal32()` / 
`decimal64()` constructors, and their `precision` / `scale` parameters
   - `_buffer.pyx`: the list of fixed-width types read as bytes
   - `iterator.py`: map both types to the existing `_decimal_iter`, which 
already decodes the value from its bytes regardless of width
   - tests against pyarrow (including negative values, slices and negative 
scale) and the API docs
   
   If you'd prefer a different shape (or to leave `list_view` / 
`run_end_encoded` out of scope, which I'd suggest), let me know.
   
   (I used Claude Code to help with the type comparison and this write-up, and 
checked the results myself.)
   


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

Reply via email to