/** * Kick-offer * * @param sql sql string * @return an intance * @throws SQLException */ private Instance runClientSQL(String sql) throws SQLException { Instance instance; try { Map<String, String> hints = new HashMap<String, String>(); Map<String, String> aliases = new HashMap<String, String>(); // If the client forget to end with a semi-colon, append it. if (!sql.contains(";")) { sql += ";"; } Odps odps = connHanlde.getOdps(); instance = SQLTask.run(odps, odps.getDefaultProject(), sql, "SQL", hints, aliases); LogView logView = new LogView(odps); if (connHanlde.getLogviewHost() != null) { logView.setLogViewHost(connHanlde.getLogviewHost()); } String logViewUrl = logView.generateLogView(instance, 7 * 24); connHanlde.log.fine("Run SQL: " + sql); connHanlde.log.info(logViewUrl); warningChain = new SQLWarning(logViewUrl); } catch (OdpsException e) { connHanlde.log.severe("fail to run sql: " + sql); throw new SQLException(e); } return instance; }
/** * Blocked SQL runner, do not print any log information * * @param sql sql string * @throws SQLException */ private void runSilentSQL(String sql) throws SQLException { try { long begin = System.currentTimeMillis(); Odps odps = connHanlde.getOdps(); SQLTask.run(odps, sql).waitForSuccess(); long end = System.currentTimeMillis(); connHanlde.log.fine("It took me " + (end - begin) + " ms to run SQL: " + sql); } catch (OdpsException e) { throw new SQLException(e); } }