maropu commented on a change in pull request #29085:
URL: https://github.com/apache/spark/pull/29085#discussion_r456978942



##########
File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveScriptTransformationExec.scala
##########
@@ -172,66 +193,95 @@ case class HiveScriptTransformationExec(
         if (!hasNext) {
           throw new NoSuchElementException
         }
-        if (outputSerde == null) {
-          val prevLine = curLine
-          curLine = reader.readLine()
-          if (!ioschema.schemaLess) {
-            new GenericInternalRow(
-              
prevLine.split(ioschema.outputRowFormatMap("TOK_TABLEROWFORMATFIELD"))
-                .map(CatalystTypeConverters.convertToCatalyst))
+        val raw = outputSerde.deserialize(scriptOutputWritable)
+        scriptOutputWritable = null
+        val dataList = outputSoi.getStructFieldsDataAsList(raw)
+        var i = 0
+        while (i < dataList.size()) {
+          if (dataList.get(i) == null) {
+            mutableRow.setNullAt(i)
           } else {
-            new GenericInternalRow(
-              
prevLine.split(ioschema.outputRowFormatMap("TOK_TABLEROWFORMATFIELD"), 2)
-                .map(CatalystTypeConverters.convertToCatalyst))
-          }
-        } else {
-          val raw = outputSerde.deserialize(scriptOutputWritable)
-          scriptOutputWritable = null
-          val dataList = outputSoi.getStructFieldsDataAsList(raw)
-          var i = 0
-          while (i < dataList.size()) {
-            if (dataList.get(i) == null) {
-              mutableRow.setNullAt(i)
-            } else {
-              unwrappers(i)(dataList.get(i), mutableRow, i)
-            }
-            i += 1
+            unwrappers(i)(dataList.get(i), mutableRow, i)
           }
-          mutableRow
+          i += 1
         }
+        mutableRow
       }
     }
+  }
+
+  override def processIterator(
+      inputIterator: Iterator[InternalRow],
+      hadoopConf: Configuration): Iterator[InternalRow] = {
+
+    val (outputStream, proc, inputStream, stderrBuffer) = initProc
+
+    // This nullability is a performance optimization in order to avoid an 
Option.foreach() call
+    // inside of a loop
+    @Nullable val (inputSerde, inputSoi) = 
initInputSerDe(input).getOrElse((null, null))
+
+    // For HiveScriptTransformationExec, if inputSerde == null, but 
outputSerde != null
+    // We will use StringBuffer to pass data, in this case, we should cast 
data as string too.
+    val finalInput = if (inputSerde == null) {
+      input.map(Cast(_, StringType).withTimeZone(conf.sessionLocalTimeZone))

Review comment:
       ```
       val finalInput = if (inputSerde == null) {
         inputExpressionsWithoutSerde
       } else {
         input
       }
   
   // The base class
     protected lazy val inputExpressionsWithoutSerde: Seq[Expression] = {
       input.map(Cast(_, StringType).withTimeZone(conf.sessionLocalTimeZone))
     }
   ```




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

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