From 52923296a946ac734c988fe10725921ea3c2b313 Mon Sep 17 00:00:00 2001 From: Xingbo Jiang Date: Fri, 15 Dec 2017 17:39:52 +0800 Subject: [PATCH] update regex pattern --- .../spark/sql/execution/datasources/v2/DataSourceV2Utils.scala | 2 +- .../apache/spark/sql/sources/v2/DataSourceV2UtilsSuite.scala | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Utils.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Utils.scala index 4794a8a18d2d1..5267f5f1580c3 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Utils.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Utils.scala @@ -42,7 +42,7 @@ private[sql] object DataSourceV2Utils extends Logging { val keyPrefix = cs.keyPrefix() require(keyPrefix != null, "The data source config key prefix can't be null.") - val pattern = Pattern.compile(s"^spark\\.datasource\\.$keyPrefix\\.(.*)") + val pattern = Pattern.compile(s"^spark\\.datasource\\.$keyPrefix\\.(.+)") conf.getAllConfs.flatMap { case (key, value) => val m = pattern.matcher(key) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2UtilsSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2UtilsSuite.scala index 42fa5a2a0282f..4911e3225552d 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2UtilsSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2UtilsSuite.scala @@ -32,6 +32,7 @@ class DataSourceV2UtilsSuite extends SparkFunSuite { conf.setConfString(s"spark.datasource.$keyPrefix.whateverConfigName", "123") conf.setConfString(s"spark.sql.$keyPrefix.config.name", "false") conf.setConfString("spark.datasource.another.config.name", "123") + conf.setConfString(s"spark.datasource.$keyPrefix.", "123") val cs = classOf[DataSourceV2WithSessionConfig].newInstance() val confs = DataSourceV2Utils.extractSessionConfigs(cs.asInstanceOf[DataSourceV2], conf) assert(confs.size == 2)