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

    https://github.com/apache/spark/pull/16417#discussion_r94210438
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
 ---
    @@ -310,6 +310,31 @@ class CodegenContext {
           // The UTF8String may came from UnsafeRow, otherwise clone is cheap 
(re-use the bytes)
           case StringType => s"$row.update($ordinal, $value.clone())"
           case udt: UserDefinedType[_] => setColumn(row, udt.sqlType, ordinal, 
value)
    +      case s: StructType if UnsafeRow.isMutable(s) =>
    +        val nestedRow = freshName("nestedRow")
    +        val updateFields = s.zipWithIndex.map { case (field, index) =>
    +          val ev = ExprCode(
    +            code = "",
    +            isNull = s"value.isNullAt($index)",
    +            value = getValue("value", field.dataType, index.toString))
    +          updateColumn(nestedRow, field.dataType, index, ev, 
field.nullable)
    +        }
    +        val updateFieldsCode = splitExpressions(
    +          updateFields, "updateFields", Seq("InternalRow" -> nestedRow, 
"InternalRow" -> "value"))
    +        val setColumnFunc = freshName("setColumnFunc")
    +        val funcCode = s"""
    +          public void $setColumnFunc(InternalRow row, InternalRow value) {
    +            if (row instanceof UnsafeRow) {
    +              ((UnsafeRow) row).setNotNullAt($ordinal);
    +              final InternalRow $nestedRow = row.getStruct($ordinal, 
${s.length});
    +              $updateFieldsCode
    --- End diff --
    
    Is `value` always `UnsafeRow`?


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

Reply via email to