Search in sources :

Example 81 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class AlluxioInterpreterTest method mkdirTest.

@Test
public void mkdirTest() throws IOException, AlluxioException {
    String qualifiedPath = "tachyon://" + mLocalAlluxioCluster.getMasterHostname() + ":" + mLocalAlluxioCluster.getMasterPort() + "/root/testFile1";
    InterpreterResult output = alluxioInterpreter.interpret("mkdir " + qualifiedPath, null);
    boolean existsDir = fs.exists(new AlluxioURI("/root/testFile1"));
    Assert.assertEquals("Successfully created directory " + qualifiedPath + "\n\n", output.message().get(0).getData());
    Assert.assertTrue(existsDir);
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) AlluxioURI(alluxio.AlluxioURI)

Example 82 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class BeamInterpreterTest method testStaticReplWithoutMain.

@Test
public void testStaticReplWithoutMain() {
    StringBuffer sourceCode = new StringBuffer();
    sourceCode.append("package org.mdkt;\n");
    sourceCode.append("public class HelloClass {\n");
    sourceCode.append("   public String hello() { return \"hello\"; }");
    sourceCode.append("}");
    InterpreterResult res = beam.interpret(sourceCode.toString(), context);
    assertEquals(InterpreterResult.Code.ERROR, res.code());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Test(org.junit.Test)

Example 83 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class BeamInterpreterTest method testStaticReplWithSyntaxError.

@Test
public void testStaticReplWithSyntaxError() {
    StringWriter writer = new StringWriter();
    PrintWriter out = new PrintWriter(writer);
    out.println("public class HelloWorld {");
    out.println("  public static void main(String args[]) {");
    out.println("    System.out.prin(\"This is in another java file\");");
    out.println("  }");
    out.println("}");
    out.close();
    InterpreterResult res = beam.interpret(writer.toString(), context);
    assertEquals(InterpreterResult.Code.ERROR, res.code());
}
Also used : StringWriter(java.io.StringWriter) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 84 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class BigQueryInterpreter method executeSql.

//Function to call bigQuery to run SQL and return results to the Interpreter for output
private InterpreterResult executeSql(String sql) {
    int counter = 0;
    StringBuilder finalmessage = null;
    finalmessage = new StringBuilder("%table ");
    String projId = getProperty(PROJECT_ID);
    long wTime = Long.parseLong(getProperty(WAIT_TIME));
    long maxRows = Long.parseLong(getProperty(MAX_ROWS));
    Iterator<GetQueryResultsResponse> pages;
    try {
        pages = run(sql, projId, wTime, maxRows);
    } catch (IOException ex) {
        logger.error(ex.getMessage());
        return new InterpreterResult(Code.ERROR, ex.getMessage());
    }
    try {
        while (pages.hasNext()) {
            finalmessage.append(printRows(pages.next()));
        }
        return new InterpreterResult(Code.SUCCESS, finalmessage.toString());
    } catch (NullPointerException ex) {
        return new InterpreterResult(Code.ERROR, ex.getMessage());
    }
}
Also used : GetQueryResultsResponse(com.google.api.services.bigquery.model.GetQueryResultsResponse) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) IOException(java.io.IOException)

Example 85 with InterpreterResult

use of org.apache.zeppelin.interpreter.InterpreterResult in project zeppelin by apache.

the class BigQueryInterpreterTest method badSqlSyntaxFails.

@Test
public void badSqlSyntaxFails() {
    InterpreterResult ret = bqInterpreter.interpret(CONSTANTS.getWrong(), context);
    assertEquals(InterpreterResult.Code.ERROR, ret.code());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Test(org.junit.Test)

Aggregations

InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)153 Test (org.junit.Test)63 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 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 LinkedList (java.util.LinkedList)3