Catch sql syntax error

This commit is contained in:
Lee moon soo 2015-04-08 09:20:51 +09:00
parent 2ebfa595b5
commit 46dba2f355
2 changed files with 8 additions and 6 deletions

View file

@ -123,11 +123,13 @@ public class SparkSqlInterpreter extends Interpreter {
sc.setLocalProperty("spark.scheduler.pool", null);
}
Object rdd = sqlc.sql(st);
String msg = ZeppelinContext.showRDD(sc, context, rdd, maxResult);
InterpreterResult rett = new InterpreterResult(Code.SUCCESS, msg);
return rett;
try {
Object rdd = sqlc.sql(st);
String msg = ZeppelinContext.showRDD(sc, context, rdd, maxResult);
return new InterpreterResult(Code.SUCCESS, msg);
} catch (Exception e) {
return new InterpreterResult(Code.ERROR, e.getMessage());
}
}
@Override

View file

@ -83,7 +83,7 @@ public class SparkSqlInterpreterTest {
assertEquals(Type.TABLE, ret.type());
assertEquals("name\tage\nmoon\t33\npark\t34\n", ret.message());
assertEquals(InterpreterResult.Code.ERROR, sql.interpret("select wrong syntax", context).code());
assertEquals(InterpreterResult.Code.ERROR, sql.interpret("select wrong syntax", context).code());
assertEquals(InterpreterResult.Code.SUCCESS, sql.interpret("select case when name==\"aa\" then name else name end from people", context).code());
}