diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConfUtil.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConfUtil.java index ae6fa43df0..acdcc1c210 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConfUtil.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConfUtil.java @@ -42,6 +42,9 @@ import java.util.StringTokenizer; import java.util.stream.Stream; +import static org.apache.hive.common.util.HiveStringUtils.COMMA; +import static org.apache.hive.common.util.HiveStringUtils.EQUALS; + /** * Hive Configuration utils */ @@ -241,15 +244,17 @@ public static String getJobCredentialProviderPassword(Configuration conf) { return null; } - private static void addKeyValuePair(Configuration jobConf, String property, String keyName, - String newKeyValue) { + private static void addKeyValuePair(Configuration jobConf, String property, String keyName, String newKeyValue) { String existingValue = jobConf.get(property); + if (existingValue == null) { - jobConf.set(property, (keyName + "=" + newKeyValue)); + jobConf.set(property, (keyName + EQUALS + newKeyValue)); return; } + String propertyValue = existingValue.contains(keyName + EQUALS) ? + HiveStringUtils.insertValue(keyName, newKeyValue, existingValue) : + existingValue + COMMA + (keyName + EQUALS + newKeyValue); - String propertyValue = HiveStringUtils.insertValue(keyName, newKeyValue, existingValue); jobConf.set(property, propertyValue); } }