-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-15743][SQL] Prevent saving with all-column partitioning #13486
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 all commits
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 |
|---|---|---|
|
|
@@ -572,4 +572,16 @@ class DataFrameReaderWriterSuite extends StreamTest with BeforeAndAfter { | |
|
|
||
| cq.awaitTermination(2000L) | ||
| } | ||
|
|
||
| test("prevent all column partitioning") { | ||
| withTempDir { dir => | ||
| val path = dir.getCanonicalPath | ||
| intercept[AnalysisException] { | ||
| spark.range(10).write.format("parquet").mode("overwrite").partitionBy("id").save(path) | ||
| } | ||
| intercept[AnalysisException] { | ||
| spark.range(10).write.format("orc").mode("overwrite").partitionBy("id").save(path) | ||
|
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. This test case is wrong, right? This exception message will be like Will fix it in my ongoing PR. My suggestion is to always verify the error message, if possible.
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. Yep. That will be fixed in #13730 .
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. Oh, I mean there is already ongoing PR.
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. I am fine if you want to fix it. You can put it in
test("prevent all column partitioning") {
withTempDir { dir =>
val path = dir.getCanonicalPath
val e = intercept[AnalysisException] {
spark.range(10).write.format("orc").mode("overwrite").partitionBy("id").save(path)
}.getMessage
assert(e.contains("Cannot use all columns for partition columns"))
}
}
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. Ah, I see what you mean. I'm going to exclude
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. I am trying to add more edge cases in the ongoing PR for improving the test coverage of |
||
| } | ||
| } | ||
| } | ||
| } | ||
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.
One little concern. If it is added here, should the method name be changed? After all it will do more than validating data types after the change.
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.
Thank you for attention, @wangyang1992 . Good point!
Maybe,
validatePartitionColumnDataTypes->validatePartitionColumnDataTypesAndCount?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.
Yeah, I think it's better.
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.
Then, let's change it. :)
Since
PartitionUtilsisprivate[sql], it's safe to be changed.I'll update this PR. Thank you for your review and idea!