Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/12856#discussion_r61975374
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/sources/HadoopFsRelationTest.scala
---
@@ -486,7 +488,143 @@ abstract class HadoopFsRelationTest extends QueryTest
with SQLTestUtils with Tes
}
}
- test("Hadoop style globbing") {
+ test("load() - with directory of unpartitioned data in nested subdirs") {
+ withTempPath { file =>
+ val dir = file.getCanonicalPath
+ val subdir = new File(dir, "subdir").getCanonicalPath
+
+ val dataInDir = Seq(1, 2, 3).toDF("value")
+ val dataInSubdir = Seq(4, 5, 6).toDF("value")
+
+ /*
+
+ Directory structure to be generated
+
+ dir
+ |
+ |___ [ files of dataInDir ]
+ |
+ |___ subsubdir
+ |
+ |___ [ files of dataInSubdir ]
+ */
+
+ // Generated dataInSubdir, not data in dir
+ partitionedTestDF1.write
+ .format(dataSourceName)
+ .mode(SaveMode.Overwrite)
+ .save(subdir)
+
+ // Inferring schema should throw error as it should not find any
file to infer
+ val e = intercept[Exception] {
+ sqlContext.read.format(dataSourceName).load(dir)
+ }
+
+ e match {
+ case _: AnalysisException =>
+ assert(e.getMessage.contains("infer"))
+
+ case _: java.util.NoSuchElementException if
e.getMessage.contains("dataSchema") =>
+ // ignore, the source format requires schema to be provided by
user
--- End diff --
The` SimpleTextSource`, used for testing purposes only, does not support
schema inference, it expects the option `dataSchema` to be present. Without
this case, `SimpleTextHadoopFsRelationSuite` fails this test with
```
org.scalatest.exceptions.TestFailedException: Expected exception
org.apache.spark.sql.AnalysisException to be thrown, but
java.util.NoSuchElementException was thrown.
sbt.ForkMain$ForkError: org.scalatest.exceptions.TestFailedException:
Expected exception org.apache.spark.sql.AnalysisException to be thrown, but
java.util.NoSuchElementException was thrown.
at
org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:496)
at
org.scalatest.FunSuite.newAssertionFailedException(FunSuite.scala:1555)
at org.scalatest.Assertions$class.intercept(Assertions.scala:1004)
at org.scalatest.FunSuite.intercept(FunSuite.scala:1555)
at
org.apache.spark.sql.sources.HadoopFsRelationTest$$anonfun$23$$anonfun$apply$mcV$sp$36.apply(HadoopFsRelationTest.scala:519)
at
org.apache.spark.sql.sources.HadoopFsRelationTest$$anonfun$23$$anonfun$apply$mcV$sp$36.apply(HadoopFsRelationTest.scala:492)
at
org.apache.spark.sql.test.SQLTestUtils$class.withTempPath(SQLTestUtils.scala:114)
at
org.apache.spark.sql.sources.HadoopFsRelationTest.withTempPath(HadoopFsRelationTest.scala:39)
at
org.apache.spark.sql.sources.HadoopFsRelationTest$$anonfun$23.apply$mcV$sp(HadoopFsRelationTest.scala:492)
at
org.apache.spark.sql.sources.HadoopFsRelationTest$$anonfun$23.apply(HadoopFsRelationTest.scala:492)
at
org.apache.spark.sql.sources.HadoopFsRelationTest$$anonfun$23.apply(HadoopFsRelationTest.scala:492)
```
---
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]