Search in sources :

Example 11 with QueryInfo

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();
}
Also used : QueryStats(io.prestosql.execution.QueryStats) Builder(io.prestosql.spi.connector.InMemoryRecordSet.Builder) TableMetadataBuilder.tableMetadataBuilder(io.prestosql.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder) BlockBuilder(io.prestosql.spi.block.BlockBuilder) QueryInfo(io.prestosql.execution.QueryInfo) BasicQueryInfo(io.prestosql.server.BasicQueryInfo) NoSuchElementException(java.util.NoSuchElementException)

Example 12 with QueryInfo

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());
}
Also used : QueryInfo(io.prestosql.execution.QueryInfo) Test(org.testng.annotations.Test)

Example 13 with QueryInfo

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);
}
Also used : QueryStats(io.prestosql.execution.QueryStats) QueryInfo(io.prestosql.execution.QueryInfo)

Example 14 with QueryInfo

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");
}
Also used : MaterializedResult(io.prestosql.testing.MaterializedResult) QueryInfo(io.prestosql.execution.QueryInfo) BasicQueryInfo(io.prestosql.server.BasicQueryInfo) Test(org.testng.annotations.Test)

Aggregations

QueryInfo (io.prestosql.execution.QueryInfo)14 BasicQueryInfo (io.prestosql.server.BasicQueryInfo)5 Test (org.testng.annotations.Test)5 URI (java.net.URI)4 QueryStats (io.prestosql.execution.QueryStats)3 Page (io.prestosql.spi.Page)3 QueryId (io.prestosql.spi.QueryId)3 BlockBuilder (io.prestosql.spi.block.BlockBuilder)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 SerializedPage (io.hetu.core.transport.execution.buffer.SerializedPage)2 DataCenterQueryResults (io.prestosql.client.DataCenterQueryResults)2 MaterializedResult (io.prestosql.testing.MaterializedResult)2 TypeLiteral (com.google.inject.TypeLiteral)1 Request (io.airlift.http.client.Request)1 Duration (io.airlift.units.Duration)1 SessionRepresentation (io.prestosql.SessionRepresentation)1 QueryResults (io.prestosql.client.QueryResults)1 DispatchManager (io.prestosql.dispatcher.DispatchManager)1 QueryManager (io.prestosql.execution.QueryManager)1