Github user rednaxelafx commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21367#discussion_r189404152
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
 ---
    @@ -220,30 +220,12 @@ case class Multiply(left: Expression, right: 
Expression) extends BinaryArithmeti
       protected override def nullSafeEval(input1: Any, input2: Any): Any = 
numeric.times(input1, input2)
     }
     
    -// scalastyle:off line.size.limit
    -@ExpressionDescription(
    -  usage = "expr1 _FUNC_ expr2 - Returns `expr1`/`expr2`. It always 
performs floating point division.",
    -  examples = """
    -    Examples:
    -      > SELECT 3 _FUNC_ 2;
    -       1.5
    -      > SELECT 2L _FUNC_ 2L;
    -       1.0
    -  """)
    -// scalastyle:on line.size.limit
    -case class Divide(left: Expression, right: Expression) extends 
BinaryArithmetic {
    -
    -  override def inputType: AbstractDataType = TypeCollection(DoubleType, 
DecimalType)
    +// Common base trait for Divide and Remainder, since these two classes are 
almost identical
    +trait DivModLike extends BinaryArithmetic {
     
    -  override def symbol: String = "/"
    -  override def decimalMethod: String = "$div"
       override def nullable: Boolean = true
     
    -  private lazy val div: (Any, Any) => Any = dataType match {
    -    case ft: FractionalType => 
ft.fractional.asInstanceOf[Fractional[Any]].div
    -  }
    -
    -  override def eval(input: InternalRow): Any = {
    +  protected def evalHelper(input: InternalRow, op: => (Any, Any) => Any): 
Any = {
    --- End diff --
    
    Note: `op` is declared as a call-by-name argument to retain the `lazy val` 
semantics of the original code in `Divide.div`.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to