-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-16006][SQL] Attemping to write empty DataFrame with no fields throws non-intuitive exception #13730
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
[SPARK-16006][SQL] Attemping to write empty DataFrame with no fields throws non-intuitive exception #13730
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…throw non-intuitive exception
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -339,6 +339,9 @@ private[sql] object PartitioningUtils { | |
| private val upCastingOrder: Seq[DataType] = | ||
| Seq(NullType, IntegerType, LongType, FloatType, DoubleType, StringType) | ||
|
|
||
| /** | ||
| * Validate partition columns for writing executions. | ||
| */ | ||
| def validatePartitionColumn( | ||
| schema: StructType, | ||
| partitionColumns: Seq[String], | ||
|
|
@@ -351,8 +354,10 @@ private[sql] object PartitioningUtils { | |
| } | ||
| } | ||
|
|
||
| if (partitionColumns.size == schema.fields.size) { | ||
| throw new AnalysisException(s"Cannot use all columns for partition columns") | ||
| if (schema.fields.isEmpty) { | ||
|
||
| throw new AnalysisException("Cannot write dataset with no fields") | ||
| } else if (partitionColumns.size == schema.fields.length) { | ||
| throw new AnalysisException("Cannot use all columns for partition columns") | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
Since
validatePartitionColumnis used for only writing-related classes, I added this description for clarification.We can update the function description if the usage pattern is changed in the future.