raulcd commented on code in PR #49845:
URL: https://github.com/apache/arrow/pull/49845#discussion_r3186779634


##########
python/pyarrow/scalar.pxi:
##########
@@ -21,6 +21,25 @@ from uuid import UUID
 from collections.abc import Sequence, Mapping
 
 
+def _is_valid_compute_operand(value):

Review Comment:
   I agree it feels overly complex, we seem to be converting the value to 
scalar and then converting again when we are doing the compute function. This 
will penalize performance. The except Exception also seems to broad. I am 
wondering if simplifying everything to just something like isn't enough?
   ```python
     def _compute_binary_op(func_name, left, right):                            
                                          
         try:        
             return _pc().call_function(func_name, [left, right])
         except TypeError:                                                      
                                          
             return NotImplemented
   ```
   This could swallow some internal `TypeError` but from my understanding 
kernel dispatch failures would raise `ArrowNotImplementedError,` (we should 
validate that calling a function with an unsupported type). So it would raise 
`TypeError` for operand conversion failures which is the one we want to return 
`NotImplemented` instead.
   We already do something really similar with `__eq__`:
   
https://github.com/apache/arrow/blob/4373fdf929a852ea8d7f9f20f1232daff90e0f86/python/pyarrow/scalar.pxi#L165-L169
   
   I haven't tested those above but those are my assumptions, if someone 
working on the problem can validate :)



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