gengliangwang commented on code in PR #37663:
URL: https://github.com/apache/spark/pull/37663#discussion_r955835818


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala:
##########
@@ -698,9 +751,14 @@ trait DivModLike extends BinaryArithmetic {
 case class Divide(
     left: Expression,
     right: Expression,
-    failOnError: Boolean = SQLConf.get.ansiEnabled) extends DivModLike {
+    evalMode: EvalMode.Value = EvalMode.fromSQLConf(SQLConf.get)) extends 
DivModLike {
+
+  def this(left: Expression, right: Expression) =
+    this(left, right, EvalMode.fromSQLConf(SQLConf.get))
 
-  def this(left: Expression, right: Expression) = this(left, right, 
SQLConf.get.ansiEnabled)
+  // `try_divide` has exactly the same behavior as the legacy divide, so here 
it only executes
+  // the error code path when `evalMode` is `ANSI`.
+  protected override def failOnError: Boolean = evalMode == EvalMode.ANSI

Review Comment:
   Yes and No. 
   In the future we may support TRY eval mode in `Interval / Number`. Thus we 
need to keep the `TRY` eval mode and resolve it in 
https://github.com/apache/spark/pull/37663/files#diff-ed19f376a63eba52eea59ca71f3355d4495fad4fad4db9a3324aade0d4986a47R443
   It doesn't seem quite necessary to add the assert now.



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