[SPARK-26081][SQL][FOLLOW-UP] Use foreach instead of misuse of map (for Unit)
## What changes were proposed in this pull request? This PR proposes to use foreach instead of misuse of map (for Unit). This could cause some weird errors potentially and it's not a good practice anyway. See also SPARK-16694 ## How was this patch tested? N/A Closes #23341 from HyukjinKwon/followup-SPARK-26081. Authored-by: Hyukjin Kwon <gurwls223@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
This commit is contained in:
parent
d72571e51d
commit
218341c5db
|
@ -189,5 +189,5 @@ private[csv] class CsvOutputWriter(
|
|||
gen.write(row)
|
||||
}
|
||||
|
||||
override def close(): Unit = univocityGenerator.map(_.close())
|
||||
override def close(): Unit = univocityGenerator.foreach(_.close())
|
||||
}
|
||||
|
|
|
@ -190,5 +190,5 @@ private[json] class JsonOutputWriter(
|
|||
gen.writeLineEnding()
|
||||
}
|
||||
|
||||
override def close(): Unit = jacksonGenerator.map(_.close())
|
||||
override def close(): Unit = jacksonGenerator.foreach(_.close())
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ class TextOutputWriter(
|
|||
private var outputStream: Option[OutputStream] = None
|
||||
|
||||
override def write(row: InternalRow): Unit = {
|
||||
val os = outputStream.getOrElse{
|
||||
val os = outputStream.getOrElse {
|
||||
val newStream = CodecStreams.createOutputStream(context, new Path(path))
|
||||
outputStream = Some(newStream)
|
||||
newStream
|
||||
|
@ -167,6 +167,6 @@ class TextOutputWriter(
|
|||
}
|
||||
|
||||
override def close(): Unit = {
|
||||
outputStream.map(_.close())
|
||||
outputStream.foreach(_.close())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue