@@ -865,16 +865,21 @@ def _op_method_error_message(self, other, op) -> str:
865865 def _evaluate_op_method (self , other , op , arrow_funcs ) -> Self :
866866 pa_type = self ._pa_array .type
867867 other_original = other
868- other_NA = self ._box_pa (other )
869- # pyarrow gets upset if you try to join a NullArray
870- other = other_NA .cast (pa_type )
868+ other = self ._box_pa (other )
871869
872870 if (
873871 pa .types .is_string (pa_type )
874872 or pa .types .is_large_string (pa_type )
875873 or pa .types .is_binary (pa_type )
876874 ):
877875 if op in [operator .add , roperator .radd ]:
876+ # pyarrow gets upset if you try to join a NullArray
877+ if (
878+ pa .types .is_integer (other .type )
879+ or pa .types .is_floating (other .type )
880+ or pa .types .is_null (other .type )
881+ ):
882+ other = other .cast (pa_type )
878883 sep = pa .scalar ("" , type = pa_type )
879884 try :
880885 if op is operator .add :
@@ -888,7 +893,7 @@ def _evaluate_op_method(self, other, op, arrow_funcs) -> Self:
888893 return self ._from_pyarrow_array (result )
889894 elif op in [operator .mul , roperator .rmul ]:
890895 binary = self ._pa_array
891- integral = other_NA
896+ integral = other
892897 if not pa .types .is_integer (integral .type ):
893898 raise TypeError ("Can only string multiply by an integer." )
894899 pa_integral = pc .if_else (pc .less (integral , 0 ), 0 , integral )
@@ -906,6 +911,13 @@ def _evaluate_op_method(self, other, op, arrow_funcs) -> Self:
906911 pa_integral = pc .if_else (pc .less (integral , 0 ), 0 , integral )
907912 result = pc .binary_repeat (binary , pa_integral )
908913 return type (self )(result )
914+ if (
915+ isinstance (other , pa .Scalar )
916+ and pc .is_null (other ).as_py ()
917+ and op .__name__ in ARROW_LOGICAL_FUNCS
918+ ):
919+ # pyarrow kleene ops require null to be typed
920+ other = other .cast (pa_type )
909921
910922 pc_func = arrow_funcs [op .__name__ ]
911923 if pc_func is NotImplemented :
0 commit comments