Skip to content

Commit b4055e1

Browse files
committed
SQLContext.getConf(key, null) should return null
1 parent 894d5a4 commit b4055e1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,10 +1228,12 @@ class SQLConf extends Serializable with Logging {
12281228
* not set yet, return `defaultValue`.
12291229
*/
12301230
def getConfString(key: String, defaultValue: String): String = {
1231-
val entry = sqlConfEntries.get(key)
1232-
if (entry != null && defaultValue != "<undefined>") {
1233-
// Only verify configs in the SQLConf object
1234-
entry.valueConverter(defaultValue)
1231+
if (defaultValue != null && defaultValue != "<undefined>") {
1232+
val entry = sqlConfEntries.get(key)
1233+
if (entry != null) {
1234+
// Only verify configs in the SQLConf object
1235+
entry.valueConverter(defaultValue)
1236+
}
12351237
}
12361238
Option(settings.get(key)).getOrElse(defaultValue)
12371239
}

sql/core/src/test/scala/org/apache/spark/sql/internal/SQLConfSuite.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,10 @@ class SQLConfSuite extends QueryTest with SharedSQLContext {
270270
val e2 = intercept[AnalysisException](spark.conf.unset(SCHEMA_STRING_LENGTH_THRESHOLD.key))
271271
assert(e2.message.contains("Cannot modify the value of a static config"))
272272
}
273+
274+
test("SPARK-21588 SQLContext.getConf(key, null) should return null") {
275+
assert(null == spark.conf.get("spark.sql.thriftServer.incrementalCollect", null))
276+
assert("<undefined>" == spark.conf.get(
277+
"spark.sql.thriftServer.incrementalCollect", "<undefined>"))
278+
}
273279
}

0 commit comments

Comments
 (0)