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



##########
File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/HiveScriptTransformationExec.scala
##########
@@ -172,66 +118,94 @@ 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))
+            unwrappers(i)(dataList.get(i), mutableRow, i)
           }
-        } 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
-          }
-          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(ioschema, 
input).getOrElse((null, null))

Review comment:
       > How about checking performance numbers with/without it?
   
   Seems not need, since we have remove these unnecessary judgement in each 
row's loop.
   It's ok to just remove it.




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to