westonpace commented on issue #35584:
URL: https://github.com/apache/arrow/issues/35584#issuecomment-1553619744

   Interesting, I wasn't aware there was a `safe` flag for `pa.array`.  It 
appears we are not using it when converting from a python sequence.
   
   ```
   import numpy as np
   import pandas as pd
   import pyarrow as pa
   
   # From numpy respects safe
   pa.array(np.array([1.2]), pa.int64()) # Fails
   pa.array(np.array([1.2]), pa.int64(), safe=False) # Succeeds
   pa.array(pd.Series([1.2]), pa.int64()) # Fails
   pa.array(pd.Series([1.2]), pa.int64(), safe=False) # Succeeds
   pa.array(pa.array([1.2]), pa.int64()) # Fails
   pa.array(pa.array([1.2]), pa.int64(), safe=False) # Succeeds
   pa.array([1.2], pa.int64()) # Succeeds, but probably shouldn't
   pa.array([1.2], pa.int64(), safe=False) # Succeeds
   ```
   
   Thus, I've changed my mind, I agree that `pa.array([1.2], type=pa.int64())` 
should fail.  However, that's both a backwards incompatible change and probably 
not a trivial feature (there is a wholly separate code path for converting 
python sequences to arrays and it doesn't seem to have a notion of safe casting 
right now).


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