Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12153#discussion_r59733711
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/sources/hadoopFsRelationSuites.scala
 ---
    @@ -668,6 +671,42 @@ abstract class HadoopFsRelationTest extends QueryTest 
with SQLTestUtils with Tes
           df.write.format(dataSourceName).partitionBy("c", "d", 
"e").saveAsTable("t")
         }
       }
    +
    +  test("Locality support for FileScanRDD") {
    +    withHadoopConf(
    +      "fs.file.impl" -> classOf[LocalityTestFileSystem].getName,
    +      "fs.file.impl.disable.cache" -> "true"
    +    ) {
    +      withTempPath { dir =>
    +        val path = "file://" + dir.getCanonicalPath
    +        val df1 = sqlContext.range(4)
    +        
df1.coalesce(1).write.mode("overwrite").format(dataSourceName).save(path)
    +        
df1.coalesce(1).write.mode("append").format(dataSourceName).save(path)
    +
    +        val df2 = sqlContext.read
    +          .format(dataSourceName)
    +          .option("dataSchema", df1.schema.json)
    +          .load(path)
    +
    +        val Some(fileScanRDD) = {
    +          def allRDDsInDAG(rdd: RDD[_]): Seq[RDD[_]] = {
    +            rdd +: rdd.dependencies.map(_.rdd).flatMap(allRDDsInDAG)
    +          }
    +
    +          // We have to search for the `FileScanRDD` along the RDD DAG 
since
    +          // RDD.preferredLocations doesn't propagate along the DAG to the 
root RDD.
    +          allRDDsInDAG(df2.rdd).collectFirst {
    +            case f: FileScanRDD => f
    +          }
    +        }
    +
    +        val partitions = fileScanRDD.partitions
    --- End diff --
    
    If we expect them be packed in the same partition, let's add an `assert`.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to