@@ -330,6 +330,10 @@ def __add__(self, other) -> Union["Series", "Index"]:
330
330
or isinstance (other , str )
331
331
):
332
332
raise TypeError ("string addition can only be applied to string series or literals." )
333
+
334
+ if isinstance (self .spark .data_type , TimestampType ):
335
+ raise TypeError ("addition can not be applied to date times." )
336
+
333
337
if isinstance (self .spark .data_type , StringType ):
334
338
# Concatenate string columns
335
339
if isinstance (other , IndexOpsMixin ) and isinstance (other .spark .data_type , StringType ):
@@ -390,6 +394,9 @@ def __mul__(self, other) -> Union["Series", "Index"]:
390
394
if isinstance (other , str ):
391
395
raise TypeError ("multiplication can not be applied to a string literal." )
392
396
397
+ if isinstance (self .spark .data_type , TimestampType ):
398
+ raise TypeError ("multiplication can not be applied to date times." )
399
+
393
400
if (
394
401
isinstance (self .spark .data_type , IntegralType )
395
402
and isinstance (other , IndexOpsMixin )
@@ -434,6 +441,9 @@ def __truediv__(self, other) -> Union["Series", "Index"]:
434
441
):
435
442
raise TypeError ("division can not be applied on string series or literals." )
436
443
444
+ if isinstance (self .spark .data_type , TimestampType ):
445
+ raise TypeError ("division can not be applied to date times." )
446
+
437
447
def truediv (left , right ):
438
448
return F .when (F .lit (right != 0 ) | F .lit (right ).isNull (), left .__div__ (right )).otherwise (
439
449
F .when (F .lit (left == np .inf ) | F .lit (left == - np .inf ), left ).otherwise (
@@ -451,6 +461,9 @@ def __mod__(self, other) -> Union["Series", "Index"]:
451
461
):
452
462
raise TypeError ("modulo can not be applied on string series or literals." )
453
463
464
+ if isinstance (self .spark .data_type , TimestampType ):
465
+ raise TypeError ("modulo can not be applied to date times." )
466
+
454
467
def mod (left , right ):
455
468
return ((left % right ) + right ) % right
456
469
@@ -461,6 +474,9 @@ def __radd__(self, other) -> Union["Series", "Index"]:
461
474
if not isinstance (self .spark .data_type , StringType ) and isinstance (other , str ):
462
475
raise TypeError ("string addition can only be applied to string series or literals." )
463
476
477
+ if isinstance (self .spark .data_type , TimestampType ):
478
+ raise TypeError ("addition can not be applied to date times." )
479
+
464
480
if isinstance (self .spark .data_type , StringType ):
465
481
if isinstance (other , str ):
466
482
return self ._with_new_scol (
@@ -507,6 +523,9 @@ def __rmul__(self, other) -> Union["Series", "Index"]:
507
523
if isinstance (other , str ):
508
524
raise TypeError ("multiplication can not be applied to a string literal." )
509
525
526
+ if isinstance (self .spark .data_type , TimestampType ):
527
+ raise TypeError ("multiplication can not be applied to date times." )
528
+
510
529
if isinstance (self .spark .data_type , StringType ):
511
530
if isinstance (other , int ):
512
531
return column_op (SF .repeat )(self , other )
@@ -521,6 +540,9 @@ def __rtruediv__(self, other) -> Union["Series", "Index"]:
521
540
if isinstance (self .spark .data_type , StringType ) or isinstance (other , str ):
522
541
raise TypeError ("division can not be applied on string series or literals." )
523
542
543
+ if isinstance (self .spark .data_type , TimestampType ):
544
+ raise TypeError ("division can not be applied to date times." )
545
+
524
546
def rtruediv (left , right ):
525
547
return F .when (left == 0 , F .lit (np .inf ).__div__ (right )).otherwise (
526
548
F .lit (right ).__truediv__ (left )
@@ -552,6 +574,9 @@ def __floordiv__(self, other) -> Union["Series", "Index"]:
552
574
):
553
575
raise TypeError ("division can not be applied on string series or literals." )
554
576
577
+ if isinstance (self .spark .data_type , TimestampType ):
578
+ raise TypeError ("division can not be applied to date times." )
579
+
555
580
def floordiv (left , right ):
556
581
return F .when (F .lit (right is np .nan ), np .nan ).otherwise (
557
582
F .when (
@@ -569,6 +594,9 @@ def __rfloordiv__(self, other) -> Union["Series", "Index"]:
569
594
if isinstance (self .spark .data_type , StringType ) or isinstance (other , str ):
570
595
raise TypeError ("division can not be applied on string series or literals." )
571
596
597
+ if isinstance (self .spark .data_type , TimestampType ):
598
+ raise TypeError ("division can not be applied to date times." )
599
+
572
600
def rfloordiv (left , right ):
573
601
return F .when (F .lit (left == 0 ), F .lit (np .inf ).__div__ (right )).otherwise (
574
602
F .when (F .lit (left ) == np .nan , np .nan ).otherwise (F .floor (F .lit (right ).__div__ (left )))
@@ -580,6 +608,9 @@ def __rmod__(self, other) -> Union["Series", "Index"]:
580
608
if isinstance (self .spark .data_type , StringType ) or isinstance (other , str ):
581
609
raise TypeError ("modulo can not be applied on string series or literals." )
582
610
611
+ if isinstance (self .spark .data_type , TimestampType ):
612
+ raise TypeError ("modulo can not be applied to date times." )
613
+
583
614
def rmod (left , right ):
584
615
return ((right % left ) + left ) % left
585
616
0 commit comments