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

    https://github.com/apache/spark/pull/7523#discussion_r35061748
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala
 ---
    @@ -68,22 +81,35 @@ case class Coalesce(children: Seq[Expression]) extends 
Expression {
         """ +
         children.map { e =>
           val eval = e.gen(ctx)
    -      s"""
    -        if (${ev.isNull}) {
    -          ${eval.code}
    -          if (!${eval.isNull}) {
    -            ${ev.isNull} = false;
    -            ${ev.primitive} = ${eval.primitive};
    -          }
    -        }
    -      """
    +      dataType match {
    +        case DoubleType | FloatType =>
    +          s"""
    +            if (${ev.isNull}) {
    +              ${eval.code}
    +              if (!${eval.isNull} && !Double.isNaN(${eval.primitive})) {
    --- End diff --
    
    I think that `Double.isNaN` is implemented internally by taking a primitive 
`double` and checking whether `x != x`, so we might be able to just inline that 
check here rather than using the more clear static method.  However, do note 
that the `x != x` trick only work if you're dealing with non-boxed primitive 
doubles; `NaN = NaN` is true when you're dealing with boxed `Double` instances.


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