working spark sql

This commit is contained in:
Prabhjyot Singh 2016-02-23 11:57:44 +05:30
parent de2fd3cd60
commit ee2dcebe35
2 changed files with 9 additions and 2 deletions

View file

@ -171,9 +171,13 @@ public class LivyHelper {
final Map<String, Integer> userSessionMap)
throws Exception {
stringLines = stringLines
//for "\n" present in string
.replaceAll("\\\\n", "\\\\\\\\n")
//for new line present in string
.replaceAll("\\n", "\\\\n")
// for \" present in string
.replaceAll("\\\\\"", "\\\\\\\\\"")
// for " present in string
.replaceAll("\"", "\\\\\"");
if (stringLines.trim().equals("")) {

View file

@ -87,8 +87,11 @@ public class LivySparkSQLInterpreter extends Interpreter {
return new InterpreterResult(InterpreterResult.Code.SUCCESS, "");
}
InterpreterResult res = livyHelper.interpret("sqlContext.sql(\"" + line + "\").show("
+ property.get("livy.spark.maxResult") + ")",
InterpreterResult res = livyHelper.interpret("sqlContext.sql(\"" +
line.replaceAll("\"", "\\\\\"")
.replaceAll("\\n", " ")
+ "\").show(" +
property.get("livy.spark.maxResult") + ")",
interpreterContext, userSessionMap);
if (res.code() == InterpreterResult.Code.SUCCESS) {