Skip to content

Commit 48d4cef

Browse files
committed
Test for load()
1 parent a443054 commit 48d4cef

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2Suite.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,21 @@ class DataSourceV2Suite extends QueryTest with SharedSQLContext {
317317
checkCanonicalizedOutput(df, 2, 2)
318318
checkCanonicalizedOutput(df.select('i), 2, 1)
319319
}
320+
321+
test("SPARK-25425: extra options override sessions options") {
322+
val prefix = "spark.datasource.test."
323+
val optionName = "optionA"
324+
withSQLConf(prefix + optionName -> "true") {
325+
val df = spark
326+
.read
327+
.option(optionName, false)
328+
.format(classOf[DataSourceWithSessionConfV2].getName).load()
329+
val options = df.queryExecution.optimizedPlan.collectFirst {
330+
case d: DataSourceV2Relation => d.options
331+
}
332+
assert(options.get.get(optionName) == Some("false"))
333+
}
334+
}
320335
}
321336

322337

@@ -385,6 +400,9 @@ class SimpleDataSourceV2 extends DataSourceV2 with BatchReadSupportProvider {
385400
}
386401
}
387402

403+
class DataSourceWithSessionConfV2 extends SimpleDataSourceV2 with SessionConfigSupport {
404+
def keyPrefix(): String = "test"
405+
}
388406

389407
class AdvancedDataSourceV2 extends DataSourceV2 with BatchReadSupportProvider {
390408

0 commit comments

Comments
 (0)