use of co.cask.cdap.proto.QueryStatus in project cdap by caskdata.
the class CLIMainTest method assertExploreQuerySuccess.
private static void assertExploreQuerySuccess(ListenableFuture<ExploreExecutionResult> dbCreationFuture) throws Exception {
ExploreExecutionResult exploreExecutionResult = dbCreationFuture.get(10, TimeUnit.SECONDS);
QueryStatus status = exploreExecutionResult.getStatus();
Assert.assertEquals(QueryStatus.OpStatus.FINISHED, status.getStatus());
}
use of co.cask.cdap.proto.QueryStatus in project cdap by caskdata.
the class InMemoryExploreServiceTest method runCommand.
private static void runCommand(String namespace, String command, boolean expectedHasResult, List<ColumnDesc> expectedColumnDescs, List<QueryResult> expectedResults) throws Exception {
QueryHandle handle = exploreService.execute(new NamespaceId(namespace), command);
QueryStatus status = waitForCompletionStatus(handle);
Assert.assertEquals(QueryStatus.OpStatus.FINISHED, status.getStatus());
Assert.assertEquals(expectedHasResult, status.hasResults());
Assert.assertEquals(expectedColumnDescs, exploreService.getResultSchema(handle));
Assert.assertEquals(expectedResults.toString(), trimColumnValues(exploreService.nextResults(handle, 100)).toString());
exploreService.close(handle);
}
use of co.cask.cdap.proto.QueryStatus in project cdap by caskdata.
the class InMemoryExploreServiceTest method waitForCompletionStatus.
private static QueryStatus waitForCompletionStatus(QueryHandle handle) throws Exception {
QueryStatus status;
do {
TimeUnit.MILLISECONDS.sleep(200);
status = exploreService.getStatus(handle);
} while (status.getStatus() == QueryStatus.OpStatus.RUNNING || status.getStatus() == QueryStatus.OpStatus.PENDING);
return status;
}
use of co.cask.cdap.proto.QueryStatus in project cdap by caskdata.
the class BaseHiveExploreService method nextResults.
@Override
public List<QueryResult> nextResults(QueryHandle handle, int size) throws ExploreException, HandleNotFoundException, SQLException {
startAndWait();
InactiveOperationInfo inactiveOperationInfo = inactiveHandleCache.getIfPresent(handle);
if (inactiveOperationInfo != null) {
// Operation has been made inactive, so all results should have been fetched already - return empty list.
LOG.trace("Returning empty result for inactive handle {}", handle);
return ImmutableList.of();
}
try {
List<QueryResult> results = fetchNextResults(handle, size);
QueryStatus status = getStatus(handle);
if (results.isEmpty() && status.getStatus() == QueryStatus.OpStatus.FINISHED) {
// Since operation has fetched all the results, handle can be timed out aggressively.
timeoutAggressively(handle, getResultSchema(handle), status);
}
return results;
} catch (HiveSQLException e) {
throw getSqlException(e);
}
}
use of co.cask.cdap.proto.QueryStatus in project cdap by caskdata.
the class BaseHiveExploreService method fetchStatus.
protected QueryStatus fetchStatus(OperationInfo operationInfo) throws ExploreException, HandleNotFoundException, HiveSQLException {
QueryStatus queryStatus;
try {
queryStatus = doFetchStatus(operationInfo.getOperationHandle());
if (QueryStatus.OpStatus.ERROR.equals(queryStatus.getStatus()) && queryStatus.getErrorMessage() == null) {
queryStatus = new QueryStatus("Operation failed. See the log for more details.", null);
}
} catch (HiveSQLException e) {
// it means that query execution failed, but we can successfully retrieve the status.
if (e.getSQLState() != null) {
queryStatus = new QueryStatus(e.getMessage(), e.getSQLState());
} else {
// this is an internal error - we are not able to retrieve the status
throw new ExploreException(e.getMessage(), e);
}
}
operationInfo.setStatus(queryStatus);
return queryStatus;
}
Aggregations