Search in sources :

Example 71 with InterpreterResult

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] ?");
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult)

Example 72 with InterpreterResult

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");
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult)

Example 73 with InterpreterResult

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");
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult)

Example 74 with InterpreterResult

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);
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult)

Example 75 with InterpreterResult

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);
}
Also used : InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult)

Aggregations

InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)159 Test (org.junit.Test)68 Properties (java.util.Properties)17 File (java.io.File)10 IOException (java.io.IOException)9 AlluxioURI (alluxio.AlluxioURI)8 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)7 Theory (org.junit.experimental.theories.Theory)7 FileWriter (java.io.FileWriter)6 PrintStream (java.io.PrintStream)5 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)5 Code (org.apache.zeppelin.interpreter.InterpreterResult.Code)5 InterpreterResultMessage (org.apache.zeppelin.interpreter.InterpreterResultMessage)5 ActionResponse (org.apache.zeppelin.elasticsearch.action.ActionResponse)4 FileInStream (alluxio.client.file.FileInStream)3 JsonObject (com.google.gson.JsonObject)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 SQLException (java.sql.SQLException)3 HashMap (java.util.HashMap)3