@@ -865,16 +865,21 @@ def _op_method_error_message(self, other, op) -> str:
865
865
def _evaluate_op_method (self , other , op , arrow_funcs ) -> Self :
866
866
pa_type = self ._pa_array .type
867
867
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 )
871
869
872
870
if (
873
871
pa .types .is_string (pa_type )
874
872
or pa .types .is_large_string (pa_type )
875
873
or pa .types .is_binary (pa_type )
876
874
):
877
875
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 )
878
883
sep = pa .scalar ("" , type = pa_type )
879
884
try :
880
885
if op is operator .add :
@@ -888,7 +893,7 @@ def _evaluate_op_method(self, other, op, arrow_funcs) -> Self:
888
893
return self ._from_pyarrow_array (result )
889
894
elif op in [operator .mul , roperator .rmul ]:
890
895
binary = self ._pa_array
891
- integral = other_NA
896
+ integral = other
892
897
if not pa .types .is_integer (integral .type ):
893
898
raise TypeError ("Can only string multiply by an integer." )
894
899
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:
906
911
pa_integral = pc .if_else (pc .less (integral , 0 ), 0 , integral )
907
912
result = pc .binary_repeat (binary , pa_integral )
908
913
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 )
909
921
910
922
pc_func = arrow_funcs [op .__name__ ]
911
923
if pc_func is NotImplemented :
0 commit comments