Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/17068#discussion_r104288543
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
---
@@ -305,13 +305,21 @@ class CSVSuite extends QueryTest with
SharedSQLContext with SQLTestUtils {
test("test with empty file and known schema") {
val result = spark.read
.format("csv")
- .schema(StructType(List(StructField("column", StringType, false))))
+ .schema(StructType(List(StructField("column", StringType, nullable =
false))))
.load(testFile(emptyFile))
- assert(result.collect.size === 0)
+ assert(result.collect().isEmpty)
assert(result.schema.fieldNames.size === 1)
}
+ test("test with empty file without schema") {
--- End diff --
Let's re-use the test in
[CSVSuite.scala#L1083](https://github.com/wojtek-szymanski/spark/blob/bdf189087c52e8934cee4ee5563dffea9dde6a99/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala#L1083).
We could..
```scala
test("Empty file produces empty dataframe with empty schema") {
Seq(false, true).foreach { wholeFile =>
val df = spark.read.format("csv")
.option("header", true)
.option("wholeFile", true)
.load(testFile(emptyFile))
assert(df.schema === spark.emptyDataFrame.schema)
checkAnswer(df, spark.emptyDataFrame)
}
}
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]