AngersZhuuuu commented on a change in pull request #33363:
URL: https://github.com/apache/spark/pull/33363#discussion_r671944145



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/BaseScriptTransformationExec.scala
##########
@@ -274,11 +278,21 @@ abstract class BaseScriptTransformationWriterThread 
extends Thread with Logging
         ioSchema.inputRowFormatMap("TOK_TABLEROWFORMATLINES")
       } else {
         val sb = new StringBuilder
-        sb.append(row.get(0, inputSchema(0)))
+        val first = row.get(0, inputSchema(0))
+        if (first == null) {
+          sb.append(ioSchema.inputRowFormatMap("TOK_TABLEROWFORMATNULL"))
+        } else {
+          sb.append(first)
+        }
         var i = 1
         while (i < len) {
           sb.append(ioSchema.inputRowFormatMap("TOK_TABLEROWFORMATFIELD"))
-          sb.append(row.get(i, inputSchema(i)))
+          val value = row.get(i, inputSchema(i))
+          if (value == null) {
+            sb.append(ioSchema.inputRowFormatMap("TOK_TABLEROWFORMATNULL"))
+          } else {
+            sb.append(value)
+          }

Review comment:
       Done

##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/BaseScriptTransformationExec.scala
##########
@@ -240,7 +240,11 @@ trait BaseScriptTransformationExec extends UnaryExecNode {
     (f: String => Any, converter: Any => Any) =>
       (data: String) => converter {
         try {
-          f(data)
+          if (data == ioschema.outputRowFormatMap("TOK_TABLEROWFORMATNULL")) {
+            null
+          } else {
+            f(data)
+          }

Review comment:
       Done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to