// Rowset is an interface in Hive 13, but a class in Hive 12, so we use reflection
// so that the compiler does not make assumption on the return type of fetchResults
Object rowSet = getCliService().fetchResults(operationHandle, FetchOrientation.FETCH_NEXT, size);
Class rowSetClass = Class.forName("org.apache.hive.service.cli.RowSet");
Method toTRowSetMethod = rowSetClass.getMethod("toTRowSet");
TRowSet tRowSet = (TRowSet) toTRowSetMethod.invoke(rowSet);
ImmutableList.Builder<QueryResult> rowsBuilder = ImmutableList.builder();
for (TRow tRow : tRowSet.getRows()) {
List<Object> cols = Lists.newArrayList();
for (TColumnValue tColumnValue : tRow.getColVals()) {
cols.add(tColumnToObject(tColumnValue));
}
rowsBuilder.add(new QueryResult(cols));