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

    https://github.com/apache/spark/pull/6755#discussion_r32193315
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
 ---
    @@ -161,15 +161,22 @@ class CodeGenContext {
       }
     
       /**
    -   * Returns a function to generate equal expression in Java
    +   * Generate code for equal expression in Java
        */
    -  def equalFunc(dataType: DataType): ((String, String) => String) = 
dataType match {
    -    case BinaryType => { case (eval1, eval2) =>
    -      s"java.util.Arrays.equals($eval1, $eval2)" }
    -    case IntegerType | BooleanType | LongType | DoubleType | FloatType | 
ShortType | ByteType =>
    -      { case (eval1, eval2) => s"$eval1 == $eval2" }
    -    case other =>
    -      { case (eval1, eval2) => s"$eval1.equals($eval2)" }
    +  def genEqual(dataType: DataType, c1: String, c2: String): String = 
dataType match {
    +    case BinaryType => s"java.util.Arrays.equals($c1, $c2)"
    +    case dt: DataType if isPrimitiveType(dt) => s"$c1 == $c2"
    +    case other => s"$c1.equals($c2)"
    +  }
    +
    +  /**
    +   * Generate code for compare expression in Java
    +   */
    +  def genComp(dataType: DataType, c1: String, c2: String): String = 
dataType match {
    +    case FloatType | DoubleType => s"(int)java.lang.Math.signum($c1 - $c2)"
    +    case dt: DataType if isPrimitiveType(dt) => s"(int)($c1 - $c2)"
    --- End diff --
    
    The first case will handle float and double, using java.lang.Math.signum


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to