@@ -309,11 +309,17 @@ trait DivModLike extends BinaryArithmetic {
309309
310310 override def nullable : Boolean = true
311311
312- final override def nullSafeEval (input1 : Any , input2 : Any ): Any = {
313- if (input2 == 0 ) {
312+ final override def eval (input : InternalRow ): Any = {
313+ val input2 = right.eval(input)
314+ if (input2 == null || input2 == 0 ) {
314315 null
315316 } else {
316- evalOperation(input1, input2)
317+ val input1 = left.eval(input)
318+ if (input1 == null ) {
319+ null
320+ } else {
321+ evalOperation(input1, input2)
322+ }
317323 }
318324 }
319325
@@ -510,18 +516,24 @@ case class Pmod(left: Expression, right: Expression) extends BinaryArithmetic {
510516
511517 override def nullable : Boolean = true
512518
513- override def nullSafeEval (input1 : Any , input2 : Any ): Any = {
514- if (input2 == 0 ) {
519+ override def eval (input : InternalRow ): Any = {
520+ val input2 = right.eval(input)
521+ if (input2 == null || input2 == 0 ) {
515522 null
516523 } else {
517- input1 match {
518- case i : Integer => pmod(i, input2.asInstanceOf [java.lang.Integer ])
519- case l : Long => pmod(l, input2.asInstanceOf [java.lang.Long ])
520- case s : Short => pmod(s, input2.asInstanceOf [java.lang.Short ])
521- case b : Byte => pmod(b, input2.asInstanceOf [java.lang.Byte ])
522- case f : Float => pmod(f, input2.asInstanceOf [java.lang.Float ])
523- case d : Double => pmod(d, input2.asInstanceOf [java.lang.Double ])
524- case d : Decimal => pmod(d, input2.asInstanceOf [Decimal ])
524+ val input1 = left.eval(input)
525+ if (input1 == null ) {
526+ null
527+ } else {
528+ input1 match {
529+ case i : Integer => pmod(i, input2.asInstanceOf [java.lang.Integer ])
530+ case l : Long => pmod(l, input2.asInstanceOf [java.lang.Long ])
531+ case s : Short => pmod(s, input2.asInstanceOf [java.lang.Short ])
532+ case b : Byte => pmod(b, input2.asInstanceOf [java.lang.Byte ])
533+ case f : Float => pmod(f, input2.asInstanceOf [java.lang.Float ])
534+ case d : Double => pmod(d, input2.asInstanceOf [java.lang.Double ])
535+ case d : Decimal => pmod(d, input2.asInstanceOf [Decimal ])
536+ }
525537 }
526538 }
527539 }
0 commit comments