cloud-fan commented on a change in pull request #24025: [SPARK-27106][SQL]
merge CaseInsensitiveStringMap and DataSourceOptions
URL: https://github.com/apache/spark/pull/24025#discussion_r264660144
##########
File path:
sql/catalyst/src/main/java/org/apache/spark/sql/util/CaseInsensitiveStringMap.java
##########
@@ -107,4 +112,49 @@ public void clear() {
public Set<Map.Entry<String, String>> entrySet() {
return delegate.entrySet();
}
+
+ /**
+ * Returns the boolean value to which the specified key is mapped,
+ * or defaultValue if there is no mapping for the key. The key match is
case-insensitive
+ */
+ public boolean getBoolean(String key, boolean defaultValue) {
+ String value = get(key);
+ // We can't use `Boolean.parseBoolean` here, as it returns false for
invalid strings.
+ if (value == null) {
+ return defaultValue;
+ } else if (value.equalsIgnoreCase("true")) {
+ return true;
+ } else if (value.equalsIgnoreCase("false")) {
+ return false;
+ } else {
+ throw new IllegalArgumentException(value + " is not a boolean string.");
+ }
+ }
+
+ /**
+ * Returns the integer value to which the specified key is mapped,
+ * or defaultValue if there is no mapping for the key. The key match is
case-insensitive
Review comment:
it's too minor to trigger another QA round. I'll fix it in another PR if the
current QA round passes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]