Github user liancheng commented on a diff in the pull request: https://github.com/apache/spark/pull/2764#discussion_r18740906 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala --- @@ -107,20 +107,20 @@ trait HiveTypeCoercion { case e if !e.childrenResolved => e /* Double Conversions */ - case b: BinaryExpression if b.left == stringNaN && b.right.dataType == DoubleType => - b.makeCopy(Array(b.right, Literal(Double.NaN))) - case b: BinaryExpression if b.left.dataType == DoubleType && b.right == stringNaN => - b.makeCopy(Array(Literal(Double.NaN), b.left)) - case b: BinaryExpression if b.left == stringNaN && b.right == stringNaN => - b.makeCopy(Array(Literal(Double.NaN), b.left)) + case b @ BinaryExpression(StringNaN, DoubleType(r)) => + b.makeCopy(Array(r, Literal(Double.NaN))) + case b @ BinaryExpression(DoubleType(l), StringNaN) => + b.makeCopy(Array(Literal(Double.NaN), l)) + case b @ BinaryExpression(l @ StringNaN, StringNaN) => + b.makeCopy(Array(Literal(Double.NaN), l)) /* Float Conversions */ - case b: BinaryExpression if b.left == stringNaN && b.right.dataType == FloatType => - b.makeCopy(Array(b.right, Literal(Float.NaN))) - case b: BinaryExpression if b.left.dataType == FloatType && b.right == stringNaN => - b.makeCopy(Array(Literal(Float.NaN), b.left)) - case b: BinaryExpression if b.left == stringNaN && b.right == stringNaN => - b.makeCopy(Array(Literal(Float.NaN), b.left)) + case b @ BinaryExpression(StringNaN, FloatType(r)) => + b.makeCopy(Array(r, Literal(Float.NaN))) + case b @ BinaryExpression(FloatType(l), StringNaN) => + b.makeCopy(Array(Literal(Float.NaN), l)) + case b @ BinaryExpression(l @ StringNaN, StringNaN) => + b.makeCopy(Array(Literal(Float.NaN), l)) --- End diff -- This case branch can never be reached since line 114 supersedes it. As a result, "NaN" is always `Double`, bug?
--- 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