-
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 4 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,30 @@ 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") | ||
| .save(dir.getCanonicalPath) | ||
| withLogAppender(logAppender) { | ||
| spark | ||
| .read | ||
| .format("avro") | ||
| .option(AvroOptions.ignoreExtensionKey, false) | ||
| .load(dir.getCanonicalPath) | ||
| .count() | ||
| } | ||
| val deprecatedEvents = logAppender.loggingEvents | ||
| .filter(_.getRenderedMessage.contains( | ||
| s"Option ${AvroOptions.ignoreExtensionKey} is deprecated")) | ||
| assert(deprecatedEvents.size === 1) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class AvroV1Suite extends AvroSuite { | ||
|
|
@@ -1521,12 +1545,10 @@ class AvroV2Suite extends AvroSuite { | |
| .write | ||
| .format("avro") | ||
| .partitionBy("p1", "p2") | ||
| .option("header", true) | ||
|
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. Ur, BTW, why do you piggy-back this removal into this PR?
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. The change is small, since I am here I remove unneeded option. Do you want to see a separate PR for the little change? |
||
| .save(dir.getCanonicalPath) | ||
| val df = spark | ||
| .read | ||
| .format("avro") | ||
| .option("header", true) | ||
| .load(dir.getCanonicalPath) | ||
| .where("p1 = 1 and p2 = 2 and value != \"a\"") | ||
|
|
||
|
|
||
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.
Can we test if the size is just bigger then 0 just in case we have other deprecation logs later?
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 compared the size to 1 to avoid any concerns that it is printed multiple times like in the PR (#27174 (comment)), per each partition.
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.
If we expect it is printed only once, maybe we should assert that?
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.
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.
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.
As we discussed in another PR, we are not going to print any log warnings about
ignoreExtension. Am I right or misunderstood something?