BigQueryInterpreter extends Interpreter { @Override public InterpreterResult interpret(String sql, InterpreterContext contextInterpreter) { logger.info("Run SQL command '{}'", sql); return executeSql(sql); } BigQueryInterpreter(Properties property); @Override void open(); static String printRows(final GetQueryResultsResponse response); static Job pollJob(final Bigquery.Jobs.Get request, final long interval); static Iterator<T> getPages(
      final BigqueryRequest<T> requestTemplate); static Iterator<GetQueryResultsResponse> run(final String queryString,
      final String projId, final long wTime, final long maxRows, Boolean useLegacySql); @Override void close(); @Override InterpreterResult interpret(String sql, InterpreterContext contextInterpreter); @Override Scheduler getScheduler(); @Override FormType getFormType(); @Override int getProgress(InterpreterContext context); @Override void cancel(InterpreterContext context); @Override List<InterpreterCompletion> completion(String buf, int cursor,
      InterpreterContext interpreterContext);  }
@Test public void sqlSuccess() { InterpreterResult ret = bqInterpreter.interpret(constants.getOne(), context); assertEquals(InterpreterResult.Code.SUCCESS, ret.code()); assertEquals(ret.message().get(0).getType(), InterpreterResult.Type.TABLE); }
@Test public void badSqlSyntaxFails() { InterpreterResult ret = bqInterpreter.interpret(constants.getWrong(), context); assertEquals(InterpreterResult.Code.ERROR, ret.code()); }
@Test public void testWithQueryPrefix() { InterpreterResult ret = bqInterpreter.interpret( "#standardSQL\n WITH t AS (select 1) SELECT * FROM t", context); assertEquals(InterpreterResult.Code.SUCCESS, ret.code()); }
@Test public void testInterpreterOutputData() { InterpreterResult ret = bqInterpreter.interpret("SELECT 1 AS col1, 2 AS col2", context); String[] lines = ret.message().get(0).getData().split("\\n"); assertEquals(2, lines.length); assertEquals("col1\tcol2", lines[0]); assertEquals("1\t2", lines[1]); }