use of io.prestosql.execution.QueryInfo in project hetu-core by openlookeng.
the class QuerySystemTable method cursor.
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) {
Builder table = InMemoryRecordSet.builder(QUERY_TABLE);
List<QueryInfo> queryInfos = queryManager.getQueries().stream().map(BasicQueryInfo::getQueryId).map(queryId -> {
try {
return queryManager.getFullQueryInfo(queryId);
} catch (NoSuchElementException e) {
return null;
}
}).filter(Objects::nonNull).collect(toImmutableList());
for (QueryInfo queryInfo : queryInfos) {
QueryStats queryStats = queryInfo.getQueryStats();
table.addRow(queryInfo.getQueryId().toString(), queryInfo.getState().toString(), queryInfo.getSession().getUser(), queryInfo.getSession().getSource().orElse(null), queryInfo.getQuery(), queryInfo.getResourceGroupId().map(QuerySystemTable::resourceGroupIdToBlock).orElse(null), toMillis(queryStats.getQueuedTime()), toMillis(queryStats.getAnalysisTime()), toMillis(queryStats.getDistributedPlanningTime()), toTimeStamp(queryStats.getCreateTime()), toTimeStamp(queryStats.getExecutionStartTime()), toTimeStamp(queryStats.getLastHeartbeat()), toTimeStamp(queryStats.getEndTime()));
}
return table.build().cursor();
}
use of io.prestosql.execution.QueryInfo in project hetu-core by openlookeng.
the class TestQueryResource method testGetQueryInfoExecutionFailure.
@Test
public void testGetQueryInfoExecutionFailure() {
String queryId = runToCompletion("SELECT cast(rand() AS integer) / 0");
QueryInfo info = getQueryInfo(queryId);
assertTrue(info.isScheduled());
assertNotNull(info.getFailureInfo());
assertEquals(info.getFailureInfo().getErrorCode(), DIVISION_BY_ZERO.toErrorCode());
}
use of io.prestosql.execution.QueryInfo in project hetu-core by openlookeng.
the class QueryResource method toFullQueryInfo.
private static QueryInfo toFullQueryInfo(DispatchQuery query) {
checkArgument(query.isDone(), "query is not done");
BasicQueryInfo info = query.getBasicQueryInfo();
BasicQueryStats stats = info.getQueryStats();
QueryStats queryStats = new QueryStats(query.getCreateTime(), query.getExecutionStartTime().orElse(null), query.getLastHeartbeat(), query.getEndTime().orElse(null), stats.getElapsedTime(), stats.getQueuedTime(), ZERO_MILLIS, ZERO_MILLIS, ZERO_MILLIS, ZERO_MILLIS, ZERO_MILLIS, ZERO_MILLIS, ZERO_MILLIS, ZERO_MILLIS, ZERO_MILLIS, 0, 0, 0, 0, 0, 0, 0, 0, 0, ZERO_BYTES, ZERO_BYTES, ZERO_BYTES, ZERO_BYTES, ZERO_BYTES, ZERO_BYTES, ZERO_BYTES, ZERO_BYTES, ZERO_BYTES, info.isScheduled(), ZERO_MILLIS, ZERO_MILLIS, ZERO_MILLIS, false, ImmutableSet.of(), ZERO_BYTES, 0, ZERO_BYTES, 0, ZERO_BYTES, 0, ZERO_BYTES, 0, ZERO_BYTES, 0, ZERO_BYTES, ImmutableList.of(), ImmutableList.of());
return new QueryInfo(info.getQueryId(), info.getSession(), info.getState(), info.getMemoryPool(), info.isScheduled(), info.getSelf(), ImmutableList.of(), info.getQuery(), info.getPreparedQuery(), queryStats, Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(), ImmutableSet.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableSet.of(), Optional.empty(), false, null, Optional.empty(), query.getDispatchInfo().getFailureInfo().orElse(null), info.getErrorCode(), ImmutableList.of(), ImmutableSet.of(), Optional.empty(), true, info.getResourceGroupId(), false);
}
use of io.prestosql.execution.QueryInfo in project hetu-core by openlookeng.
the class AbstractTestDistributedQueries method testWrittenStats.
@Test
public void testWrittenStats() {
String sql = "CREATE TABLE test_written_stats AS SELECT * FROM nation";
DistributedQueryRunner distributedQueryRunner = (DistributedQueryRunner) getQueryRunner();
ResultWithQueryId<MaterializedResult> resultResultWithQueryId = distributedQueryRunner.executeWithQueryId(getSession(), sql);
QueryInfo queryInfo = distributedQueryRunner.getCoordinator().getQueryManager().getFullQueryInfo(resultResultWithQueryId.getQueryId());
assertEquals(queryInfo.getQueryStats().getOutputPositions(), 1L);
assertEquals(queryInfo.getQueryStats().getWrittenPositions(), 25L);
assertTrue(queryInfo.getQueryStats().getLogicalWrittenDataSize().toBytes() > 0L);
sql = "INSERT INTO test_written_stats SELECT * FROM nation LIMIT 10";
resultResultWithQueryId = distributedQueryRunner.executeWithQueryId(getSession(), sql);
queryInfo = distributedQueryRunner.getCoordinator().getQueryManager().getFullQueryInfo(resultResultWithQueryId.getQueryId());
assertEquals(queryInfo.getQueryStats().getOutputPositions(), 1L);
assertEquals(queryInfo.getQueryStats().getWrittenPositions(), 10L);
assertTrue(queryInfo.getQueryStats().getLogicalWrittenDataSize().toBytes() > 0L);
assertUpdate("DROP TABLE test_written_stats");
}
Aggregations