@@ -22,16 +22,19 @@ import org.apache.spark.sql.test.SharedSQLContext
22
22
class FileBasedDataSourceSuite extends QueryTest with SharedSQLContext {
23
23
import testImplicits ._
24
24
25
- Seq (" orc" , " parquet" , " csv" , " json" , " text" ).foreach { format =>
25
+ private val allFileBasedDataSources = Seq (" orc" , " parquet" , " csv" , " json" , " text" )
26
+
27
+ allFileBasedDataSources.foreach { format =>
26
28
test(s " Writing empty datasets should not fail - $format" ) {
27
29
withTempPath { dir =>
28
30
Seq (" str" ).toDS().limit(0 ).write.format(format).save(dir.getCanonicalPath)
29
31
}
30
32
}
31
33
}
32
34
33
- Seq (" orc" , " parquet" , " csv" , " json" ).foreach { format =>
34
- test(s " SPARK-23072 Write and read back unicode schema - $format" ) {
35
+ // `TEXT` data source always has a single column whose name is `value`.
36
+ allFileBasedDataSources.filterNot(_ == " text" ).foreach { format =>
37
+ test(s " SPARK-23072 Write and read back unicode column names - $format" ) {
35
38
withTempPath { path =>
36
39
val dir = path.getCanonicalPath
37
40
@@ -42,12 +45,14 @@ class FileBasedDataSourceSuite extends QueryTest with SharedSQLContext {
42
45
df.write.format(format).option(" header" , " true" ).save(dir)
43
46
val answerDf = spark.read.format(format).option(" header" , " true" ).load(dir)
44
47
45
- assert(df.schema === answerDf.schema)
48
+ assert(df.schema.sameType( answerDf.schema) )
46
49
checkAnswer(df, answerDf)
47
50
}
48
51
}
49
52
}
50
53
54
+ // Only ORC/Parquet support this. `CSV` and `JSON` returns an empty schema.
55
+ // `TEXT` data source always has a single column whose name is `value`.
51
56
Seq (" orc" , " parquet" ).foreach { format =>
52
57
test(s " SPARK-15474 Write and read back non-emtpy schema with empty dataframe - $format" ) {
53
58
withTempPath { file =>
@@ -62,7 +67,7 @@ class FileBasedDataSourceSuite extends QueryTest with SharedSQLContext {
62
67
}
63
68
}
64
69
65
- Seq ( " orc " , " parquet " , " csv " , " json " , " text " ) .foreach { format =>
70
+ allFileBasedDataSources .foreach { format =>
66
71
test(s " SPARK-22146 read files containing special characters using $format" ) {
67
72
val nameWithSpecialChars = s " sp&cial%chars "
68
73
withTempDir { dir =>
0 commit comments