ROdps { public List<String> runSqlTask(String sql) throws ROdpsException { if (!sql.contains(";")) { sql += ";"; } LOG.debug("sql: " + sql); try { Instance instance = SQLTask.run(odps, odps.getDefaultProject(), sql, "rodps_sql_task", settings, null); LogView logView = new LogView(odps); if (LOGVIEW_HOST != null) { logView.setLogViewHost(LOGVIEW_HOST); } String logViewUrl = logView.generateLogView(instance, 7 * 24); System.err.println(logViewUrl); LOG.info(logViewUrl); instance.waitForSuccess(); Map<String, String> results = instance.getTaskResults(); String result = results.get("rodps_sql_task"); if (result == null||result.isEmpty()) { return new ArrayList<String>(); } return Arrays.asList(results.get("rodps_sql_task").split("\n")); } catch (Exception e) { LOG.error("runSqlTask error,sql=" + sql, e); throw new ROdpsException(e); } } ROdps(String projectName, String accessID, String accessKey, String endPoint,
      String dtEndpoint, String logviewHost, String log4j_properties); void setBizId(String s); void set(String key, String value); void unset(String key); void writeTableFromDT(String projectName, String tableName, String partition,
      String dataFilePathName, String columnDelimiter, String rowDelimiter, long recordCount,
      int threadNumber); List<List<String>> loadTableFromDT(String projectName, String tableName, String partition,
      String tempFile, String colDelimiter, String rowDelimiter, int limit, int threadNumber); boolean useProject(String projectName); String getProjectName(String projectName); long getTableSize(String projectName, String tableName, String partition); List<DataFrameItem> describeTable(String projectName, String tableName, String partition); boolean dropTable(String projectName, String tableName); boolean isTableExist(String projectName, String tableName, String partition); String getTableSchemaJson(String projectName, String tableName); int getIndexFromColName(String colName, String tableSchemaJson); List<String> runSqlTask(String sql); List<DataFrameItem> getTables(String projectName, String pattern); static String formatPartition(String part, String valueDim, String fieldDim); boolean setLogPath(String log_path);  }
@Test public void testRunSqlTask() throws ROdpsException { List<String> ret = rodps.runSqlTask("create table if not exists odps_r_operator(id int);"); assertNotNull(ret); assertEquals(0, ret.size()); ret = rodps.runSqlTask("insert into table odps_r_operator select 1 from dual;"); assertNotNull(ret); assertEquals(0, ret.size()); }