mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
address comments
This commit is contained in:
parent
151e991427
commit
f57d7bbf61
2 changed files with 13 additions and 4 deletions
|
|
@ -341,9 +341,7 @@ public class SparkInterpreter extends Interpreter {
|
|||
*/
|
||||
public Object createSparkSession() {
|
||||
// use local mode for embedded spark mode when spark.master is not found
|
||||
if (!conf.contains("spark.master")) {
|
||||
conf.setMaster("local");
|
||||
}
|
||||
conf.setIfMissing("spark.master", "local");
|
||||
logger.info("------ Create new SparkSession {} -------", conf.get("spark.master"));
|
||||
String execUri = System.getenv("SPARK_EXECUTOR_URI");
|
||||
if (outputDir != null) {
|
||||
|
|
|
|||
|
|
@ -151,13 +151,24 @@ public class RemoteInterpreter extends Interpreter {
|
|||
sparkConfBuilder.append(" --master " + property.getProperty("master"));
|
||||
}
|
||||
if (isSparkConf(key, property.getProperty(key))) {
|
||||
sparkConfBuilder.append(" --conf " + key + "=" + property.getProperty(key));
|
||||
sparkConfBuilder.append(" --conf " + key + "=\"" +
|
||||
toShellFormat(property.getProperty(key)) + "\"");
|
||||
}
|
||||
}
|
||||
env.put("ZEPPELIN_SPARK_CONF", sparkConfBuilder.toString());
|
||||
return env;
|
||||
}
|
||||
|
||||
private String toShellFormat(String value) {
|
||||
if (value.contains("\'") && value.contains("\"")) {
|
||||
throw new RuntimeException("Spark property value could not contain both \" and '");
|
||||
} else if (value.contains("\'")) {
|
||||
return "\"" + value + "\"";
|
||||
} else {
|
||||
return "\'" + value + "\'";
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isSparkConf(String key, String value) {
|
||||
return !StringUtils.isEmpty(key) && key.startsWith("spark.") && !StringUtils.isEmpty(value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue