Github user dbtsai commented on a diff in the pull request: https://github.com/apache/spark/pull/17606#discussion_r110979361 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala --- @@ -571,6 +571,7 @@ object TypeCoercion { NaNvl(l, Cast(r, DoubleType)) case NaNvl(l, r) if l.dataType == FloatType && r.dataType == DoubleType => NaNvl(Cast(l, DoubleType), r) + case NaNvl(l, r) if r.dataType == NullType => NaNvl(l, Cast(r, l.dataType)) --- End diff -- Yeah, this PR prevents casting from `NaNvl(FloatType, NullType)` to `NaNvl(DoubleType, DoubleType)` since we want to minimize the casting as much as possible. Also, if we want to replace `NaN` by `null`, we want to keep the output type the same as input type. Whether `NaNvl(FloatType, DoubleType)` should be cast into `NaNvl(DoubleType, DoubleType)` is another story. I agree with you, we should downcast the replacement `DoubleType` into `FloatType`. And in my opinion, doing this implicit casting is error-prone, and we should do explicit casting by users instead. @gatorsmile maybe you can chime in, and give the feedback whether we should cast `NaNvl(FloatType, DoubleType)` to `NaNvl(DoubleType, DoubleType)`.
--- 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