yaooqinn commented on a change in pull request #35132:
URL: https://github.com/apache/spark/pull/35132#discussion_r781009424
##########
File path:
sql/hive/src/main/scala/org/apache/spark/sql/hive/orc/OrcFileFormat.scala
##########
@@ -299,11 +292,26 @@ private[orc] class OrcOutputWriter(
}
override def close(): Unit = {
- if (recordWriterInstantiated) {
+ try {
+ OrcUtils.addSparkVersionMetadata(getOrCreateInternalWriter())
+ } catch {
+ case NonFatal(e) => log.warn(e.toString, e)
+ }
+ recordWriter.close(Reporter.NULL)
+ }
+
+ private def getOrCreateInternalWriter(): Writer = {
+ val writerField = recordWriter.getClass.getDeclaredField("writer")
+ writerField.setAccessible(true)
+ var writer = writerField.get(recordWriter).asInstanceOf[Writer]
+ if (writer == null) {
Review comment:
org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat.OrcRecordWriter init
`writer` while writing the first element without synchronizing and we call
`write` and `close` serially. I guess it's safe here
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]