Github user liancheng commented on a diff in the pull request: https://github.com/apache/spark/pull/12153#discussion_r59594996 --- 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 -- Not necessarily, and probably only 1, since both files written are pretty small and will be merged into a single partition.
--- 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