Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7955#discussion_r36284557
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/ScriptTransformation.scala
 ---
    @@ -226,12 +228,25 @@ private class ScriptTransformationWriterThread(
         // We can't use Utils.tryWithSafeFinally here because we also need a 
`catch` block, so
         // let's use a variable to record whether the `finally` block was hit 
due to an exception
         var threwException: Boolean = true
    +    val len = outputSchema.length
         try {
           iter.map(outputProjection).foreach { row =>
             if (inputSerde == null) {
    -          val data = row.mkString("", 
ioschema.inputRowFormatMap("TOK_TABLEROWFORMATFIELD"),
    -            
ioschema.inputRowFormatMap("TOK_TABLEROWFORMATLINES")).getBytes("utf-8")
    -          outputStream.write(data)
    +          val data = if (len == 0) {
    +            ioschema.inputRowFormatMap("TOK_TABLEROWFORMATLINES")
    +          } else {
    +            val sb = new StringBuilder
    +            sb.append(row.get(0, outputSchema(0)))
    +            var i = 1
    +            while (i < len) {
    +              
sb.append(ioschema.inputRowFormatMap("TOK_TABLEROWFORMATFIELD"))
    +              sb.append(row.get(i, outputSchema(i)))
    --- End diff --
    
    A test failed here because of `ArrayIndexOutOfBoundsException`. However, 
the `outputProjection` is created by `child.output` 
[here](https://github.com/apache/spark/pull/7955/files#diff-c8a2a0ed4963fdb9256bc8d8a83977bdR81)
 and the `outputSchema` is also created by `child.output` 
[here](https://github.com/apache/spark/pull/7955/files#diff-c8a2a0ed4963fdb9256bc8d8a83977bdR91),
 I'll look into this.


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