Github user ueshin commented on a diff in the pull request:
https://github.com/apache/spark/pull/3150#discussion_r20001270
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
---
@@ -323,28 +371,53 @@ case class Cast(child: Expression, dataType:
DataType) extends UnaryExpression w
buildCast[Date](_, d => dateToDouble(d))
case TimestampType =>
buildCast[Timestamp](_, t => timestampToDouble(t).toFloat)
- case DecimalType() =>
- buildCast[Decimal](_, _.toFloat)
case x: NumericType =>
b => x.numeric.asInstanceOf[Numeric[Any]].toFloat(b)
}
- private[this] lazy val cast: Any => Any = dataType match {
+ private[this] def castArray(from: ArrayType, to: ArrayType): Any => Any
= {
+ val elementCast = cast(from.elementType, to.elementType)
+ buildCast[Seq[Any]](_, _.map(v => if (v == null) null else
elementCast(v)))
--- End diff --
I don't think we need to handle the case specially the same as other
expressions.
The element data of the type `ArrayType.containsNull == false` are never
`null`, so always `elementCast(v)` will be called.
---
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]