wjones127 commented on PR #37292:
URL: https://github.com/apache/arrow/pull/37292#issuecomment-1687384784

   Python example:
   
   ```python
   >>> import pyarrow as pa
   >>> arr = pa.array([[1, 2, 3], [4, 5, 6]])
   >>> arr.type
   ListType(list<item: int64>)
   >>> arr.cast(pa.list_(pa.int64(), 3))
   <pyarrow.lib.FixedSizeListArray object at 0x132793e80>
   [
     [
       1,
       2,
       3
     ],
     [
       4,
       5,
       6
     ]
   ]
   >>> arr.cast(pa.list_(pa.int64(), 3)).cast(pa.list_(pa.int64()))
   <pyarrow.lib.ListArray object at 0x132793ee0>
   [
     [
       1,
       2,
       3
     ],
     [
       4,
       5,
       6
     ]
   ]
   >>> arr.cast(pa.list_(pa.int64(), 2))
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "pyarrow/array.pxi", line 967, in pyarrow.lib.Array.cast
       return _pc().cast(self, target_type, safe=safe,
     File "/Users/willjones/Documents/arrow/python/pyarrow/compute.py", line 
403, in cast
       return call_function("cast", [arr], options, memory_pool)
     File "pyarrow/_compute.pyx", line 572, in pyarrow._compute.call_function
       return func.call(args, options=options, memory_pool=memory_pool,
     File "pyarrow/_compute.pyx", line 367, in pyarrow._compute.Function.call
       result = GetResultValue(
     File "pyarrow/error.pxi", line 144, in 
pyarrow.lib.pyarrow_internal_check_status
       return check_status(status)
     File "pyarrow/error.pxi", line 100, in pyarrow.lib.check_status
       raise ArrowInvalid(message)
   pyarrow.lib.ArrowInvalid: ListType can only be casted to FixedSizeListType 
if the lists are all the expected size.
   /Users/willjones/Documents/arrow/cpp/src/arrow/compute/exec.cc:920  
kernel_->exec(kernel_ctx_, input, &output)
   /Users/willjones/Documents/arrow/cpp/src/arrow/compute/function.cc:276  
executor->Execute(input, &listener)
   ```


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