MaxGekk commented on a change in pull request #27174: [SPARK-30490][SQL]
Eliminate compiler warnings in Avro datasource
URL: https://github.com/apache/spark/pull/27174#discussion_r365596481
##########
File path:
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroOptions.scala
##########
@@ -78,7 +80,17 @@ class AvroOptions(
parameters
.get(AvroOptions.ignoreExtensionKey)
.map(_.toBoolean)
- .getOrElse(!ignoreFilesWithoutExtension)
+ .map { ignoreExtensionOption =>
+ if (ignoreExtensionOption != !ignoreFilesWithoutExtensionByDefault) {
+ warn(s"The Avro option '${AvroOptions.ignoreExtensionKey}'")
Review comment:
@HyukjinKwon you are right, it prints warnings per each partition. I have
confirmed that by the test:
```scala
test("count deprecation log events") {
val partitionNum = 3
val logAppender = new AppenderSkeleton {
val loggingEvents = new ArrayBuffer[LoggingEvent]()
override def append(loggingEvent: LoggingEvent): Unit =
loggingEvents.append(loggingEvent)
override def close(): Unit = {}
override def requiresLayout(): Boolean = false
}
withTempPath { dir =>
Seq(("a", 1, 2), ("b", 1, 2), ("c", 2, 1), ("d", 2, 1))
.toDF("value", "p1", "p2")
.repartition(partitionNum)
.write
.format("avro")
.option("header", true)
.save(dir.getCanonicalPath)
withLogAppender(logAppender) {
val df = spark
.read
.format("avro")
.schema("value STRING, p1 INTEGER, p2 INTEGER")
.option(AvroOptions.ignoreExtensionKey, false)
.option("header", true)
.load(dir.getCanonicalPath)
df.count()
}
val deprecatedEvents = logAppender.loggingEvents
.map(_.getRenderedMessage)
.filter(_.contains(AvroOptions.ignoreExtensionKey))
assert(deprecatedEvents.size === partitionNum)
}
}
```
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]