Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/6537#discussion_r31393869
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala
---
@@ -127,20 +127,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, r @ DoubleType()) =>
+ b.makeCopy(Array(r, Literal(Double.NaN)))
+ case b @ BinaryExpression(l @ DoubleType(), StringNaN) =>
+ b.makeCopy(Array(Literal(Double.NaN), l))
/* Float Conversions */
- case b: BinaryExpression if b.left == stringNaN &&
b.right.dataType == FloatType =>
+ case b @ BinaryExpression(StringNaN, r @ 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(l @ FloatType(), StringNaN) =>
--- End diff --
unrelated to this pr, but i find l somewhat hard to differentiate from 1.
might be better in the future to use left vs right
---
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]