randolf-scholz commented on issue #34987:
URL: https://github.com/apache/arrow/issues/34987#issuecomment-1501722888

   @jorisvandenbossche 
   
   > We could also say: if you want python-like scalar behaviour, just call 
as_py() on the pyarrow scalar.
   (and we could also raise an error in __bool__ always, to make it clear this 
method isn't actually implemented)
   
   Certainly that could be better than the current situation. I opened this 
issue after the following code silently failed:
   
   ```python
   assert pa.compute.all(pa.compute.invert(array.is_null())
   ```
   
   >  Currently `__eq__` is very dumb, so doing `pa.scalar(None) == 
pa.scalar(None)` gives `True` (while that doesn't match element-wise equality 
behavior for the array with equivalent values) or it requires exact types 
(again not being consistent with the element-wise "equal" kernel)
   
   That just seems really bad behavior as well. 
`pa.compute.equal(pa.scalar(None, type=pa.bool_()), pa.scalar(None, 
type=pa.bool_()))` returns `<pyarrow.BooleanScalar: None>`, so 
`(pa.scalar(None, type=pa.bool_()), pa.scalar(None, type=pa.bool_())` should 
return this as well. This should be fine, since if the result of this equality 
will be used in context where a python boolean is expected the casting to bool 
will raise the TypeError, if we follow option 1 from my other comment.
   


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