Skip to content

Commit 2f7c523

Browse files
committed
Updated test for SimpleTextHadoopFsRelationSuite
1 parent 3bb42bd commit 2f7c523

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/sources/HadoopFsRelationTest.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,20 @@ abstract class HadoopFsRelationTest extends QueryTest with SQLTestUtils with Tes
516516
.save(subdir)
517517

518518
// Inferring schema should throw error as it should not find any file to infer
519-
val e = intercept[AnalysisException] {
519+
val e = intercept[Exception] {
520520
sqlContext.read.format(dataSourceName).load(dir)
521521
}
522-
assert(e.getMessage.contains("infer"))
522+
523+
e match {
524+
case _: AnalysisException =>
525+
assert(e.getMessage.contains("infer"))
526+
527+
case _: java.util.NoSuchElementException if e.getMessage.contains("dataSchema") =>
528+
// ignore, the source format requires schema to be provided by user
529+
530+
case _ =>
531+
fail("Unexpected error trying to infer schema from empty dir", e)
532+
}
523533

524534
/** Test whether data is read with the given path matches the expected answer */
525535
def testWithPath(path: String, expectedAnswer: Seq[Row]): Unit = {

0 commit comments

Comments
 (0)