use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_exception_when_executing_unknown_bound_statement.
@Test
public void should_exception_when_executing_unknown_bound_statement() throws Exception {
//Given
String queries = "@bind[select_users]='jdoe'";
//When
final InterpreterResult actual = interpreter.interpret(queries, intrContext);
//Then
assertThat(actual.code()).isEqualTo(Code.ERROR);
assertThat(actual.message().get(0).getData()).isEqualTo("The statement 'select_users' can not be bound to values. " + "Are you sure you did prepare it with @prepare[select_users] ?");
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_error_describing_non_existing_table.
@Test
public void should_error_describing_non_existing_table() throws Exception {
//Given
String query = "USE system;\n" + "DESCRIBE TABLE complex_table;";
//When
final InterpreterResult actual = interpreter.interpret(query, intrContext);
//Then
assertThat(actual.code()).isEqualTo(Code.ERROR);
assertThat(actual.message().get(0).getData()).contains("Cannot find table system.complex_table");
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_execute_bound_statement_with_no_bound_value.
@Test
public void should_execute_bound_statement_with_no_bound_value() throws Exception {
//Given
String queries = "@prepare[select_no_bound_value]=SELECT name,country,styles FROM zeppelin.artists LIMIT 3\n" + "@bind[select_no_bound_value]";
//When
final InterpreterResult actual = interpreter.interpret(queries, intrContext);
//Then
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
assertThat(actual.message().get(0).getData()).isEqualTo("name\tcountry\tstyles\n" + "Bogdan Raczynski\tPoland\t[Dance, Electro]\n" + "Krishna Das\tUSA\t[Unknown]\n" + "Sheryl Crow\tUSA\t[Classic, Rock, Country, Blues, Pop, Folk]\n");
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_describe_table.
@Test
public void should_describe_table() throws Exception {
//Given
String query = "DESCRIBE TABLE live_data.complex_table;";
final String expected = reformatHtml(readTestResource("/scalate/DescribeTable_live_data_complex_table.html"));
//When
final InterpreterResult actual = interpreter.interpret(query, intrContext);
//Then
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class MockInterpreterA method interpret.
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
try {
Thread.sleep(Long.parseLong(st));
this.lastSt = st;
} catch (NumberFormatException | InterruptedException e) {
throw new InterpreterException(e);
}
return new InterpreterResult(Code.SUCCESS, st);
}
Aggregations