Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/18412#discussion_r123878391
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
---
@@ -482,15 +482,15 @@ case class Cast(child: Expression, dataType:
DataType, timeZoneId: Option[String
case (fromField, toField) => cast(fromField.dataType,
toField.dataType)
}
// TODO: Could be faster?
- val newRow = new GenericInternalRow(from.fields.length)
buildCast[InternalRow](_, row => {
+ val newRow = new GenericInternalRow(from.fields.length)
var i = 0
while (i < row.numFields) {
newRow.update(i,
if (row.isNullAt(i)) null else castFuncs(i)(row.get(i,
from.apply(i).dataType)))
i += 1
}
- newRow.copy()
--- End diff --
instead of having a same row instance and copy it every time, I think it
makes more sense to create a different row everytime.
Besides, I also had a PR to fix this:
https://github.com/apache/spark/pull/15082 . Maybe I should reopen it...
---
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]