Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18412#discussion_r124062223
  
    --- 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 --
    
    @hvanhovell I found the semantics of the original 
`GenericMutableRow.copy()` pretty dangerous since it didn't properly implement 
deep copy semantics. In fact, it's impossible to do a proper deep copy there. 
We only copy the underlying field array but may still share field objects 
accidentally.
    
    If we do want to "fix" `GenericInternalRow.copy()`, I'd prefer throwing an 
exception instead of following the old `GenericMutableRow.copy()` method.


---
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

Reply via email to