Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/5017#discussion_r26448902
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
---
@@ -394,10 +394,17 @@ case class Cast(child: Expression, dataType:
DataType) extends UnaryExpression w
val casts = from.fields.zip(to.fields).map {
case (fromField, toField) => cast(fromField.dataType,
toField.dataType)
}
- // TODO: This is very slow!
- buildCast[Row](_, row => Row(row.toSeq.zip(casts).map {
- case (v, cast) => if (v == null) null else cast(v)
- }: _*))
+ // TODO: Could be faster?
+ val newRow = new GenericMutableRow(from.fields.size)
+ buildCast[Row](_, row => {
+ var i = 0
+ while (i < row.length) {
+ val v = row(i)
+ newRow.update(i, if (v == null) null else casts(i)(v))
+ i += 1
+ }
+ newRow.copy()
--- End diff --
If the returned func has been called multiple times, wouldn't it cause
problem?
---
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]