public ClientProtos.ExecuteResponse execute(String sql, String sessionId,
ReadModel readModel, boolean closeSession, int fetchSize)
throws ServiceException {
try {
long beforeGenPlan = EnvironmentEdgeManager.currentTimeMillis();
ParseContext context = new ParseContext();
context.setTsr(TableSchemaCacheReader.getInstance(service
.getConfiguration()));
context.setSql(sql);
context.setReadModel(readModel);
context.setSessionId(sessionId);
try {
if (StringUtils.isNotEmpty(sessionId)) {
Parser.SQLType sqlType = parser.getSQLType(context);
if(sqlType == Parser.SQLType.DQL) {
context.setPlan(new DQLPlan());
} else {
parser.generatePlan(context);
}
} else {
parser.generatePlan(context);
}
} catch (RuntimeException e) {
if (e instanceof ParserException || e instanceof SQLParseException) {
throw new DoNotRetryIOException(e.getMessage(), e);
} else {
throw new ServiceException(new IOException(e));
}
} catch (UnsupportedException e) {
throw e;
}
final long afterGenPlan = EnvironmentEdgeManager.currentTimeMillis();
((FServer) this.service).getMetrics().updateGenPlan(
afterGenPlan - beforeGenPlan);
Plan executePlan = context.getPlan();
if (executePlan instanceof DQLPlan) {
selectSQLCount.increment();
DQLPlan dqlPlan = (DQLPlan) executePlan;
dqlPlan.setFetchRows(fetchSize);
Pair<Boolean, Pair<String, Pair<List<QueryResultProto>, List<StringDataTypePair>>>> queryResults =