}
CellSet executeInternalQuery(@NotNull ThinQuery query) throws Exception {
String runId = "RUN#:" + ID_GENERATOR.getAndIncrement();
QueryContext queryContext = context.get(query.getName());
if (queryContext == null) {
queryContext = new QueryContext(query);
this.context.put(query.getName(), queryContext);
}
OlapConnection con = olapDiscoverService.getNativeConnection(query.getCube().getConnection());
if (StringUtils.isNotBlank(query.getCube().getCatalog())) {
con.setCatalog(query.getCube().getCatalog());
}
if (queryContext.contains(ObjectKey.STATEMENT)) {
Statement s = queryContext.getStatement();
s.cancel();
s.close();
s = null;
queryContext.remove();
}
OlapStatement stmt = con.createStatement();
queryContext.store(ObjectKey.STATEMENT, stmt);
query = updateQuery(query);
try {
String mdx = query.getParameterResolvedMdx();
LOG.info(runId + "\tType:" + query.getType() + ":\n" + mdx);
CellSet cs = stmt.executeOlapQuery(mdx);
queryContext.store(ObjectKey.RESULT, cs);
queryContext.store(ObjectKey.QUERY, query);
return cs;
} finally {
stmt.close();
queryContext.remove();
}
}