Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,17 @@ trait SQLConf {
}

def get(key: String): String = {
if (!settings.containsKey(key)) {
throw new NoSuchElementException(key)
}
settings.get(key)
Option(settings.get(key)).getOrElse(throw new NoSuchElementException(key))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably adding the checking logic is better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. How about Option(settings.get(key)).orElse(throw new NoSuchElementException(key))?

}

def get(key: String, defaultValue: String): String = {
if (!settings.containsKey(key)) defaultValue else settings.get(key)
Option(settings.get(key)).getOrElse(defaultValue)
}

def getAll: Array[(String, String)] = settings.asScala.toArray

def getOption(key: String): Option[String] = {
if (!settings.containsKey(key)) None else Some(settings.get(key))
Option(settings.get(key))
}

def contains(key: String): Boolean = settings.containsKey(key)
Expand Down