viirya commented on code in PR #55938:
URL: https://github.com/apache/spark/pull/55938#discussion_r3261847386


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala:
##########
@@ -301,31 +301,22 @@ abstract class BinaryArithmetic extends BinaryOperator 
with SupportQueryContext
       val mathUtils = 
IntervalMathUtils.getClass.getCanonicalName.stripSuffix("$")
       defineCodeGen(ctx, ev, (eval1, eval2) => 
s"$mathUtils.${exactMathMethod.get}($eval1, $eval2)")
     // byte and short are casted into int when add, minus, times or divide
+    case ByteType | ShortType if failOnError =>
+      val opName = symbol match {
+        case "+" => "Add"
+        case "-" => "Subtract"
+        case "*" => "Multiply"
+        case _ =>
+          throw 
QueryExecutionErrors.notOverrideExpectedMethodsError(this.getClass.getName,
+            s"genCode for Byte/Short with symbol '$symbol'", "genCode")

Review Comment:
   In practice, only Add/Subtract/Multiply reach BinaryArithmetic.doGenCode 
with byte/short (Divide/Remainder/Pmod/IntegralDivide override doGenCode via 
DivModLike). Reasonable defensive coding, but the 
notOverrideExpectedMethodsError message ("genCode") is a slightly awkward fit — 
it's normally used for missing method overrides, not for a runtime symbol 
mismatch. A SparkException.internalError(s"Unexpected symbol $symbol for 
Byte/Short BinaryArithmetic") would read more accurately.



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

To unsubscribe, e-mail: [email protected]

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