Skip to content

Commit e5b5751

Browse files
committed
Data source options should be propagated in method checkAndGlobPathIfNecessary
1 parent 37b7d32 commit e5b5751

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ case class DataSource(
570570
checkEmptyGlobPath: Boolean,
571571
checkFilesExist: Boolean): Seq[Path] = {
572572
val allPaths = caseInsensitiveOptions.get("path") ++ paths
573-
val hadoopConf = sparkSession.sessionState.newHadoopConf()
573+
val hadoopConf = sparkSession.sessionState.newHadoopConfWithOptions(options)
574574

575575
DataSource.checkAndGlobPathIfNecessary(allPaths.toSeq, hadoopConf,
576576
checkEmptyGlobPath, checkFilesExist)

sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/DataSourceSuite.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ package org.apache.spark.sql.execution.datasources
1919

2020
import org.apache.hadoop.conf.Configuration
2121
import org.apache.hadoop.fs.{FileStatus, Path, RawLocalFileSystem}
22+
import org.scalatest.PrivateMethodTester
2223

2324
import org.apache.spark.sql.AnalysisException
2425
import org.apache.spark.sql.test.SharedSparkSession
2526

26-
class DataSourceSuite extends SharedSparkSession {
27+
class DataSourceSuite extends SharedSparkSession with PrivateMethodTester {
2728
import TestPaths._
2829

2930
test("test glob and non glob paths") {
@@ -132,6 +133,18 @@ class DataSourceSuite extends SharedSparkSession {
132133
)
133134
)
134135
}
136+
137+
test("Data source options should be propagated in method checkAndGlobPathIfNecessary") {
138+
val fsDefaultName = "mockFs://mockFs"
139+
val dataSource =
140+
DataSource(spark, "parquet", Seq("/path1"), options = Map("fs.defaultFS" -> fsDefaultName))
141+
val checkAndGlobPathIfNecessary = PrivateMethod[Seq[Path]]('checkAndGlobPathIfNecessary)
142+
143+
val message = intercept[java.io.IOException] {
144+
dataSource invokePrivate checkAndGlobPathIfNecessary(false, false)
145+
}.getMessage
146+
assert(message.equals("No FileSystem for scheme: mockFs"))
147+
}
135148
}
136149

137150
object TestPaths {

0 commit comments

Comments
 (0)