Github user dilipbiswal commented on a diff in the pull request: https://github.com/apache/spark/pull/20579#discussion_r167659522 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/FileBasedDataSourceSuite.scala --- @@ -72,6 +72,29 @@ class FileBasedDataSourceSuite extends QueryTest with SharedSQLContext { } } + // Text and Parquet format does not allow wrting data frame with empty schema. + Seq("parquet", "text").foreach { format => + test(s"SPARK-23372 writing empty dataframe should produce AnalysisException - $format") { + withTempPath { outputPath => + intercept[AnalysisException] { + spark.emptyDataFrame.write.format(format).save(outputPath.toString) + } + } + } + } + + // Formats excluding text and parquet allow writing empty data frames to files. + allFileBasedDataSources.filterNot(p => p == "text" || p == "parquet").foreach { format => + test(s"SPARK-23372 writing empty dataframe and reading from it - $format") { + withTempPath { outputPath => + spark.emptyDataFrame.write.format(format).save(outputPath.toString) + intercept[AnalysisException] { + val df = spark.read.format(format).load(outputPath.toString) --- End diff -- @hvanhovell Actually thats my question as well. Please see my comment [comment/question](https://github.com/apache/spark/pull/20579#issuecomment-364994881)
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org