[ZEPPELIN-1965] Livy SQL Interpreter: Should use df.show(1000, false) to display results

This commit is contained in:
Benoy Antony 2017-03-28 23:24:31 -07:00
parent 4a466d0605
commit b6252be466
2 changed files with 11 additions and 2 deletions

View file

@ -36,10 +36,12 @@ public class LivySparkSQLInterpreter extends BaseLivyInterprereter {
private boolean isSpark2 = false;
private int maxResult = 1000;
private boolean truncate = true;
public LivySparkSQLInterpreter(Properties property) {
super(property);
this.maxResult = Integer.parseInt(property.getProperty("zeppelin.livy.spark.sql.maxResult"));
this.truncate = Boolean.parseBoolean(property.getProperty("zeppelin.livy.spark.sql.truncate"));
}
@Override
@ -111,9 +113,11 @@ public class LivySparkSQLInterpreter extends BaseLivyInterprereter {
// use triple quote so that we don't need to do string escape.
String sqlQuery = null;
if (isSpark2) {
sqlQuery = "spark.sql(\"\"\"" + line + "\"\"\").show(" + maxResult + ")";
sqlQuery = "spark.sql(\"\"\"" + line + "\"\"\").show(" + maxResult + ", " +
truncate + ")";
} else {
sqlQuery = "sqlContext.sql(\"\"\"" + line + "\"\"\").show(" + maxResult + ")";
sqlQuery = "sqlContext.sql(\"\"\"" + line + "\"\"\").show(" + maxResult + ", " +
truncate + ")";
}
InterpreterResult result = sparkInterpreter.interpret(sqlQuery, context.getParagraphId(),
this.displayAppInfo, true);

View file

@ -118,6 +118,11 @@
"defaultValue": "1000",
"description": "Max number of Spark SQL result to display."
},
"zeppelin.livy.spark.sql.truncate": {
"propertyName": "zeppelin.livy.spark.sql.truncate",
"defaultValue": "true",
"description": "If true, truncate strings greater than 20 characters."
},
"zeppelin.livy.concurrentSQL": {
"propertyName": "zeppelin.livy.concurrentSQL",
"defaultValue": "false",