Skip to content

Commit d3a4d3c

Browse files
Fix the potential bug of referencing FileSystem
1 parent 1f033cd commit d3a4d3c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/TableReader.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ class HadoopTableReader(
6868
math.max(sc.hiveconf.getInt("mapred.map.tasks", 1), sc.sparkContext.defaultMinPartitions)
6969
}
7070

71-
@transient private lazy val fs = FileSystem.get(sc.hiveconf)
72-
7371
// TODO: set aws s3 credentials.
7472

7573
private val _broadcastedHiveConf =
@@ -220,6 +218,7 @@ class HadoopTableReader(
220218
* returned in a single, comma-separated string.
221219
*/
222220
private def applyFilterIfNeeded(path: Path, filterOpt: Option[PathFilter]): Option[String] = {
221+
val fs = path.getFileSystem(sc.hiveconf)
223222
if (fs.exists(path)) {
224223
// if the file exists
225224
filterOpt match {

sql/hive/src/test/scala/org/apache/spark/sql/hive/QueryPartitionSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package org.apache.spark.sql.hive
1919

2020
import org.scalatest.BeforeAndAfter
2121

22-
import org.apache.spark.sql.hive.test.TestHive._
2322
import org.apache.spark.util.Utils
23+
import org.apache.spark.sql.hive.test.TestHive._
2424
import org.apache.spark.sql.hive.execution.HiveComparisonTest
2525

2626
abstract class QueryPartitionSuite extends HiveComparisonTest with BeforeAndAfter {
@@ -78,4 +78,4 @@ class QueryPartitionSuite2 extends QueryPartitionSuite {
7878

7979
createQueryTest("SPARK-5068 scan table with non-existed path",
8080
"select key,value from table_with_partition", false)
81-
}
81+
}

0 commit comments

Comments
 (0)