Skip to content

Commit 4512d72

Browse files
committed
Move to FileBasedDataSourceSuite
1 parent c2891d0 commit 4512d72

File tree

3 files changed

+39
-64
lines changed

3 files changed

+39
-64
lines changed

sql/core/src/test/scala/org/apache/spark/sql/FileBasedDataSourceSuite.scala

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
package org.apache.spark.sql
1919

20+
import org.apache.hadoop.fs.Path
21+
22+
import org.apache.spark.SparkException
23+
import org.apache.spark.sql.internal.SQLConf
2024
import org.apache.spark.sql.test.SharedSQLContext
2125

2226
class FileBasedDataSourceSuite extends QueryTest with SharedSQLContext {
@@ -92,4 +96,39 @@ class FileBasedDataSourceSuite extends QueryTest with SharedSQLContext {
9296
}
9397
}
9498
}
99+
100+
// Only ORC/Parquet support this.
101+
Seq("orc", "parquet").foreach { format =>
102+
testQuietly(s"Enabling/disabling ignoreMissingFiles using $format") {
103+
def testIgnoreMissingFiles(): Unit = {
104+
withTempDir { dir =>
105+
val basePath = dir.getCanonicalPath
106+
spark.range(1).toDF("a").write.format(format).save(new Path(basePath, "first").toString)
107+
spark.range(1, 2).toDF("a").write.format(format)
108+
.save(new Path(basePath, "second").toString)
109+
val thirdPath = new Path(basePath, "third")
110+
spark.range(2, 3).toDF("a").write.format(format).save(thirdPath.toString)
111+
val df = spark.read.format(format).load(
112+
new Path(basePath, "first").toString,
113+
new Path(basePath, "second").toString,
114+
new Path(basePath, "third").toString)
115+
116+
val fs = thirdPath.getFileSystem(spark.sparkContext.hadoopConfiguration)
117+
assert(fs.delete(thirdPath, true))
118+
checkAnswer(df, Seq(Row(0), Row(1)))
119+
}
120+
}
121+
122+
withSQLConf(SQLConf.IGNORE_MISSING_FILES.key -> "true") {
123+
testIgnoreMissingFiles()
124+
}
125+
126+
withSQLConf(SQLConf.IGNORE_MISSING_FILES.key -> "false") {
127+
val exception = intercept[SparkException] {
128+
testIgnoreMissingFiles()
129+
}
130+
assert(exception.getMessage().contains("does not exist"))
131+
}
132+
}
133+
}
95134
}

sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/orc/OrcQuerySuite.scala

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -655,35 +655,4 @@ class OrcQuerySuite extends OrcQueryTest with SharedSQLContext {
655655
}
656656
}
657657
}
658-
659-
testQuietly("Enabling/disabling ignoreMissingFiles") {
660-
def testIgnoreMissingFiles(): Unit = {
661-
withTempDir { dir =>
662-
val basePath = dir.getCanonicalPath
663-
spark.range(1).toDF("a").write.orc(new Path(basePath, "first").toString)
664-
spark.range(1, 2).toDF("a").write.orc(new Path(basePath, "second").toString)
665-
val thirdPath = new Path(basePath, "third")
666-
spark.range(2, 3).toDF("a").write.orc(thirdPath.toString)
667-
val df = spark.read.orc(
668-
new Path(basePath, "first").toString,
669-
new Path(basePath, "second").toString,
670-
new Path(basePath, "third").toString)
671-
672-
val fs = thirdPath.getFileSystem(spark.sparkContext.hadoopConfiguration)
673-
assert(fs.delete(thirdPath, true))
674-
checkAnswer(df, Seq(Row(0), Row(1)))
675-
}
676-
}
677-
678-
withSQLConf(SQLConf.IGNORE_MISSING_FILES.key -> "true") {
679-
testIgnoreMissingFiles()
680-
}
681-
682-
withSQLConf(SQLConf.IGNORE_MISSING_FILES.key -> "false") {
683-
val exception = intercept[SparkException] {
684-
testIgnoreMissingFiles()
685-
}
686-
assert(exception.getMessage().contains("does not exist"))
687-
}
688-
}
689658
}

sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -355,39 +355,6 @@ class ParquetQuerySuite extends QueryTest with ParquetTest with SharedSQLContext
355355
}
356356
}
357357

358-
testQuietly("Enabling/disabling ignoreMissingFiles") {
359-
def testIgnoreMissingFiles(): Unit = {
360-
withTempDir { dir =>
361-
val basePath = dir.getCanonicalPath
362-
spark.range(1).toDF("a").write.parquet(new Path(basePath, "first").toString)
363-
spark.range(1, 2).toDF("a").write.parquet(new Path(basePath, "second").toString)
364-
val thirdPath = new Path(basePath, "third")
365-
spark.range(2, 3).toDF("a").write.parquet(thirdPath.toString)
366-
val df = spark.read.parquet(
367-
new Path(basePath, "first").toString,
368-
new Path(basePath, "second").toString,
369-
new Path(basePath, "third").toString)
370-
371-
val fs = thirdPath.getFileSystem(spark.sparkContext.hadoopConfiguration)
372-
fs.delete(thirdPath, true)
373-
checkAnswer(
374-
df,
375-
Seq(Row(0), Row(1)))
376-
}
377-
}
378-
379-
withSQLConf(SQLConf.IGNORE_MISSING_FILES.key -> "true") {
380-
testIgnoreMissingFiles()
381-
}
382-
383-
withSQLConf(SQLConf.IGNORE_MISSING_FILES.key -> "false") {
384-
val exception = intercept[SparkException] {
385-
testIgnoreMissingFiles()
386-
}
387-
assert(exception.getMessage().contains("does not exist"))
388-
}
389-
}
390-
391358
/**
392359
* this is part of test 'Enabling/disabling ignoreCorruptFiles' but run in a loop
393360
* to increase the chance of failure

0 commit comments

Comments
 (0)