use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class JDBCInterpreterTest method testSelectQuery.
@Test
public void testSelectQuery() throws SQLException, IOException {
Properties properties = new Properties();
properties.setProperty("common.max_count", "1000");
properties.setProperty("common.max_retry", "3");
properties.setProperty("default.driver", "org.h2.Driver");
properties.setProperty("default.url", getJdbcConnection());
properties.setProperty("default.user", "");
properties.setProperty("default.password", "");
JDBCInterpreter t = new JDBCInterpreter(properties);
t.open();
String sqlQuery = "select * from test_table WHERE ID in ('a', 'b')";
InterpreterResult interpreterResult = t.interpret(sqlQuery, interpreterContext);
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.message().get(0).getType());
assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n", interpreterResult.message().get(0).getData());
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class JDBCInterpreterTest method testSelectMultipleQuries.
@Test
public void testSelectMultipleQuries() throws SQLException, IOException {
Properties properties = new Properties();
properties.setProperty("common.max_count", "1000");
properties.setProperty("common.max_retry", "3");
properties.setProperty("default.driver", "org.h2.Driver");
properties.setProperty("default.url", getJdbcConnection());
properties.setProperty("default.user", "");
properties.setProperty("default.password", "");
JDBCInterpreter t = new JDBCInterpreter(properties);
t.open();
String sqlQuery = "select * from test_table;" + "select * from test_table WHERE ID = ';';";
InterpreterResult interpreterResult = t.interpret(sqlQuery, interpreterContext);
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
assertEquals(2, interpreterResult.message().size());
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.message().get(0).getType());
assertEquals("ID\tNAME\na\ta_name\nb\tb_name\nc\tnull\n", interpreterResult.message().get(0).getData());
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.message().get(1).getType());
assertEquals("ID\tNAME\n", interpreterResult.message().get(1).getData());
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_bind_boolean_value.
@Test
public void should_bind_boolean_value() throws Exception {
//Given
String queries = "@prepare[bind_boolean]=INSERT INTO zeppelin.users(login,deceased) VALUES(?,?)\n" + "@bind[bind_boolean]='bind_bool',false\n" + "SELECT login,deceased FROM zeppelin.users WHERE login='bind_bool';";
//When
final InterpreterResult actual = interpreter.interpret(queries, intrContext);
//Then
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
assertThat(actual.message().get(0).getData()).isEqualTo("login\tdeceased\n" + "bind_bool\tfalse\n");
}
use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.
the class CassandraInterpreterTest method should_describe_udt_withing_logged_in_keyspace.
@Test
public void should_describe_udt_withing_logged_in_keyspace() throws Exception {
//Given
String query = "USE live_data;\n" + "DESCRIBE TYPE address;";
final String expected = reformatHtml(readTestResource("/scalate/DescribeType_live_data_address_within_current_keyspace.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 CassandraInterpreterTest method should_throw_statement_not_having_semi_colon.
@Test
public void should_throw_statement_not_having_semi_colon() throws Exception {
//Given
String statement = "SELECT * zeppelin.albums";
//When
final InterpreterResult actual = interpreter.interpret(statement, intrContext);
//Then
assertThat(actual.code()).isEqualTo(Code.ERROR);
assertThat(actual.message().get(0).getData()).contains("Error parsing input:\n" + "\t'SELECT * zeppelin.albums'\n" + "Did you forget to add ; (semi-colon) at the end of each CQL statement ?");
}
Aggregations