-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-30509][SQL] Fix deprecation log warning in Avro schema inferring #27200
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 2 commits
47879d9
0bb33aa
11cbf2e
6c53b50
164cf5b
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 |
|---|---|---|
|
|
@@ -1497,6 +1497,32 @@ abstract class AvroSuite extends QueryTest with SharedSparkSession { | |
| |} | ||
| """.stripMargin) | ||
| } | ||
|
|
||
| test("log a warning of ignoreExtension deprecation") { | ||
| val logAppender = new LogAppender | ||
| withTempPath { dir => | ||
| Seq(("a", 1, 2), ("b", 1, 2), ("c", 2, 1), ("d", 2, 1)) | ||
| .toDF("value", "p1", "p2") | ||
| .repartition(2) | ||
| .write | ||
| .format("avro") | ||
| .option("header", true) | ||
| .save(dir.getCanonicalPath) | ||
| withLogAppender(logAppender) { | ||
| spark | ||
| .read | ||
| .format("avro") | ||
| .option(AvroOptions.ignoreExtensionKey, false) | ||
| .option("header", true) | ||
| .load(dir.getCanonicalPath) | ||
| .count() | ||
| } | ||
| val deprecatedEvents = logAppender.loggingEvents | ||
| .filter(_.getRenderedMessage.contains( | ||
| s"Option ${AvroOptions.ignoreExtensionKey} is deprecated")) | ||
| assert(deprecatedEvents.size === 1) | ||
|
Member
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. Can we test if the size is just bigger then 0 just in case we have other deprecation logs later?
Member
Author
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. I compared the size to 1 to avoid any concerns that it is printed multiple times like in the PR (#27174 (comment)), per each partition.
Member
Author
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. If we expect it is printed only once, maybe we should assert that?
Member
Author
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. So, if somebody modifies the code in the future in the way the warning is printed many times, we will catch the situation by the test.
Member
Author
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.
As we discussed in another PR, we are not going to print any log warnings about |
||
| } | ||
| } | ||
| } | ||
|
|
||
| class AvroV1Suite extends AvroSuite { | ||
|
|
||
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.
Does Avro has header option?
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.
I copy pasted the piece of code from another test in AvroSuite:
spark/external/avro/src/test/scala/org/apache/spark/sql/avro/AvroSuite.scala
Line 1524 in 94fc0e3
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.
Yeh, it is not needed. It seems the test which I copy-pasted was copy-pasted from another places. I guess from
spark/sql/core/src/test/scala/org/apache/spark/sql/FileBasedDataSourceSuite.scala
Lines 746 to 787 in b389b8c
Let me remove the option from other avro test as well.