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

    https://github.com/apache/spark/pull/15059#discussion_r78725648
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvalHelper.scala
 ---
    @@ -289,13 +290,32 @@ trait ExpressionEvalHelper extends 
GeneratorDrivenPropertyChecks {
         (result, expected) match {
           case (result: Array[Byte], expected: Array[Byte]) =>
             java.util.Arrays.equals(result, expected)
    -      case (result: Double, expected: Spread[Double @unchecked]) =>
    -        expected.asInstanceOf[Spread[Double]].isWithin(result)
           case (result: Double, expected: Double) if result.isNaN && 
expected.isNaN =>
             true
    +      case (result: Double, expected: Double) =>
    +        relativeErrorComparison(result, expected)
           case (result: Float, expected: Float) if result.isNaN && 
expected.isNaN =>
             true
           case _ => result == expected
         }
       }
    +
    +  /**
    +   * Private helper function for comparing two values using relative 
tolerance.
    +   * Note that if x or y is extremely close to zero, i.e., smaller than 
Double.MinPositiveValue,
    +   * the relative tolerance is meaningless, so the exception will be 
raised to warn users.
    +   */
    +  private def relativeErrorComparison(x: Double, y: Double, eps: Double = 
1E-8): Boolean = {
    --- End diff --
    
    I've add comment to indicate the problem. Thank you!


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to