cloud-fan commented on a change in pull request #29882:
URL: https://github.com/apache/spark/pull/29882#discussion_r504489335



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -360,22 +372,24 @@ trait DivModLike extends BinaryArithmetic {
         boolean ${ev.isNull} = false;
         $javaType ${ev.value} = ${CodeGenerator.defaultValue(dataType)};
         if ($isZero) {
-          ${ev.isNull} = true;
+          $divByZero
         } else {
           ${eval1.code}
           ${ev.value} = $operation;
         }""")
     } else {
       ev.copy(code = code"""
-        ${eval2.code}

Review comment:
       we should run `eval2` first, as we have a chance to skip `eval1` if 
`eval2` is 0.
   
   This is also why we didn't use `nullSafeEval` before, to control the 
evaluation order.
   
   It would be great if you can help to write this down as code comments, so 
that other people won't make the same mistake in the future.




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to