mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Catch sql syntax error
This commit is contained in:
parent
2ebfa595b5
commit
46dba2f355
2 changed files with 8 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue