-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-38075][SQL] Fix hasNext
in HiveScriptTransformationExec
's process output iterator
#35368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ private[hive] case class HiveScriptTransformationExec( | |
outputSoi: StructObjectInspector, | ||
hadoopConf: Configuration): Iterator[InternalRow] = { | ||
new Iterator[InternalRow] with HiveInspectors { | ||
var curLine: String = null | ||
var completed = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: private |
||
val scriptOutputStream = new DataInputStream(inputStream) | ||
|
||
val scriptOutputReader = | ||
|
@@ -78,13 +78,17 @@ private[hive] case class HiveScriptTransformationExec( | |
lazy val unwrappers = outputSoi.getAllStructFieldRefs.asScala.map(unwrapperFor) | ||
|
||
override def hasNext: Boolean = { | ||
if (completed) { | ||
return false | ||
} | ||
try { | ||
if (scriptOutputWritable == null) { | ||
scriptOutputWritable = reusedWritableObject | ||
|
||
if (scriptOutputReader != null) { | ||
if (scriptOutputReader.next(scriptOutputWritable) <= 0) { | ||
checkFailureAndPropagate(writerThread, null, proc, stderrBuffer) | ||
completed = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, I could just set |
||
return false | ||
} | ||
} else { | ||
|
@@ -97,6 +101,7 @@ private[hive] case class HiveScriptTransformationExec( | |
// there can be a lag between EOF being written out and the process | ||
// being terminated. So explicitly waiting for the process to be done. | ||
checkFailureAndPropagate(writerThread, null, proc, stderrBuffer) | ||
completed = true | ||
return false | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this is irrelevant to this correctness issue, the clean-up looks okay.