Search in sources :

Example 1 with QueryStats

use of io.prestosql.execution.QueryStats in project hetu-core by openlookeng.

the class TestMemorySmoke method testSemiJoinDynamicFilteringNone.

@Test
public void testSemiJoinDynamicFilteringNone() {
    final long buildSideRowsCount = 15_000L;
    Session session = Session.builder(getSession()).setSystemProperty(ENABLE_DYNAMIC_FILTERING, "true").setSystemProperty(JOIN_DISTRIBUTION_TYPE, FeaturesConfig.JoinDistributionType.BROADCAST.name()).build();
    DistributedQueryRunner runner = (DistributedQueryRunner) getQueryRunner();
    ResultWithQueryId<MaterializedResult> result = runner.executeWithQueryId(session, "SELECT * FROM lineitem WHERE orderkey IN (SELECT orderkey from orders WHERE totalprice < 0)");
    assertEquals(result.getResult().getRowCount(), 0);
    QueryStats stats = runner.getCoordinator().getQueryManager().getFullQueryInfo(result.getQueryId()).getQueryStats();
    Set rowsRead = stats.getOperatorSummaries().stream().filter(summary -> summary.getOperatorType().equals("ScanFilterAndProjectOperator")).map(summary -> summary.getInputPositions()).collect(toImmutableSet());
    assertEquals(rowsRead, ImmutableSet.of(0L, buildSideRowsCount));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ResultWithQueryId(io.prestosql.tests.ResultWithQueryId) Language(org.intellij.lang.annotations.Language) Set(java.util.Set) Test(org.testng.annotations.Test) QueryStats(io.prestosql.execution.QueryStats) MaterializedRow(io.prestosql.testing.MaterializedRow) MaterializedResult(io.prestosql.testing.MaterializedResult) String.format(java.lang.String.format) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) AbstractTestQueryFramework(io.prestosql.tests.AbstractTestQueryFramework) Assert.assertEquals(io.prestosql.testing.assertions.Assert.assertEquals) List(java.util.List) ENABLE_DYNAMIC_FILTERING(io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Session(io.prestosql.Session) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Assert.assertTrue(org.testng.Assert.assertTrue) JOIN_DISTRIBUTION_TYPE(io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) QueryStats(io.prestosql.execution.QueryStats) MaterializedResult(io.prestosql.testing.MaterializedResult) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Example 2 with QueryStats

use of io.prestosql.execution.QueryStats in project hetu-core by openlookeng.

the class TestBasicQueryInfo method testConstructor.

@Test
public void testConstructor() {
    BasicQueryInfo basicInfo = new BasicQueryInfo(new QueryInfo(new QueryId("0"), TEST_SESSION.toSessionRepresentation(), RUNNING, new MemoryPoolId("reserved"), false, URI.create("1"), ImmutableList.of("2", "3"), "SELECT 4", Optional.empty(), new QueryStats(DateTime.parse("1991-09-06T05:00-05:30"), DateTime.parse("1991-09-06T05:01-05:30"), DateTime.parse("1991-09-06T05:02-05:30"), DateTime.parse("1991-09-06T06:00-05:30"), Duration.valueOf("8m"), Duration.valueOf("7m"), Duration.valueOf("34m"), Duration.valueOf("35m"), Duration.valueOf("44m"), Duration.valueOf("9m"), Duration.valueOf("10m"), Duration.valueOf("11m"), Duration.valueOf("12m"), Duration.valueOf("12m"), Duration.valueOf("12m"), 13, 14, 15, 16, 17, 18, 34, 19, 20.0, DataSize.valueOf("21GB"), DataSize.valueOf("22GB"), DataSize.valueOf("23GB"), DataSize.valueOf("24GB"), DataSize.valueOf("25GB"), DataSize.valueOf("26GB"), DataSize.valueOf("27GB"), DataSize.valueOf("28GB"), DataSize.valueOf("29GB"), true, Duration.valueOf("23m"), Duration.valueOf("24m"), Duration.valueOf("26m"), true, ImmutableSet.of(BlockedReason.WAITING_FOR_MEMORY), DataSize.valueOf("271GB"), 281, DataSize.valueOf("272GB"), 282, DataSize.valueOf("27GB"), 28, DataSize.valueOf("29GB"), 30, DataSize.valueOf("31GB"), 32, DataSize.valueOf("32GB"), ImmutableList.of(new StageGcStatistics(101, 102, 103, 104, 105, 106, 107)), ImmutableList.of()), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(), ImmutableSet.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableSet.of(), Optional.empty(), false, "33", Optional.empty(), null, StandardErrorCode.ABANDONED_QUERY.toErrorCode(), ImmutableList.of(), ImmutableSet.of(), Optional.empty(), false, Optional.empty(), false));
    assertEquals(basicInfo.getQueryId().getId(), "0");
    assertEquals(basicInfo.getState(), RUNNING);
    assertEquals(basicInfo.getMemoryPool().getId(), "reserved");
    assertEquals(basicInfo.isScheduled(), false);
    assertEquals(basicInfo.getQuery(), "SELECT 4");
    assertEquals(basicInfo.getQueryStats().getCreateTime(), DateTime.parse("1991-09-06T05:00-05:30"));
    assertEquals(basicInfo.getQueryStats().getEndTime(), DateTime.parse("1991-09-06T06:00-05:30"));
    assertEquals(basicInfo.getQueryStats().getElapsedTime(), Duration.valueOf("8m"));
    assertEquals(basicInfo.getQueryStats().getExecutionTime(), Duration.valueOf("44m"));
    assertEquals(basicInfo.getQueryStats().getTotalDrivers(), 16);
    assertEquals(basicInfo.getQueryStats().getQueuedDrivers(), 17);
    assertEquals(basicInfo.getQueryStats().getRunningDrivers(), 18);
    assertEquals(basicInfo.getQueryStats().getCompletedDrivers(), 19);
    assertEquals(basicInfo.getQueryStats().getCumulativeUserMemory(), 20.0);
    assertEquals(basicInfo.getQueryStats().getUserMemoryReservation(), DataSize.valueOf("21GB"));
    assertEquals(basicInfo.getQueryStats().getTotalMemoryReservation(), DataSize.valueOf("23GB"));
    assertEquals(basicInfo.getQueryStats().getPeakUserMemoryReservation(), DataSize.valueOf("24GB"));
    assertEquals(basicInfo.getQueryStats().getTotalCpuTime(), Duration.valueOf("24m"));
    assertEquals(basicInfo.getQueryStats().isFullyBlocked(), true);
    assertEquals(basicInfo.getQueryStats().getBlockedReasons(), ImmutableSet.of(BlockedReason.WAITING_FOR_MEMORY));
    assertEquals(basicInfo.getQueryStats().getProgressPercentage(), OptionalDouble.of(100));
    assertEquals(basicInfo.getErrorCode(), StandardErrorCode.ABANDONED_QUERY.toErrorCode());
    assertEquals(basicInfo.getErrorType(), StandardErrorCode.ABANDONED_QUERY.toErrorCode().getType());
}
Also used : QueryStats(io.prestosql.execution.QueryStats) QueryId(io.prestosql.spi.QueryId) QueryInfo(io.prestosql.execution.QueryInfo) StageGcStatistics(io.prestosql.spi.eventlistener.StageGcStatistics) MemoryPoolId(io.prestosql.spi.memory.MemoryPoolId) Test(org.testng.annotations.Test)

Example 3 with QueryStats

use of io.prestosql.execution.QueryStats in project hetu-core by openlookeng.

the class Query method toStatementStats.

private StatementStats toStatementStats(QueryInfo queryInfo) {
    QueryStats queryStats = queryInfo.getQueryStats();
    // Dont print any more stats for Async Query,
    StageInfo outputStage = queryInfo.isRunningAsync() ? null : queryInfo.getOutputStage().orElse(null);
    return StatementStats.builder().setState(queryInfo.getState().toString()).setQueued(queryInfo.getState() == QueryState.QUEUED).setScheduled(queryInfo.isScheduled()).setNodes(globalUniqueNodes(outputStage, false).size()).setTotalSplits(queryStats.getTotalDrivers()).setQueuedSplits(queryStats.getQueuedDrivers()).setRunningSplits(queryStats.getRunningDrivers() + queryStats.getBlockedDrivers()).setCompletedSplits(queryStats.getCompletedDrivers()).setCpuTimeMillis(queryStats.getTotalCpuTime().toMillis()).setWallTimeMillis(queryStats.getTotalScheduledTime().toMillis()).setQueuedTimeMillis(queryStats.getQueuedTime().toMillis()).setElapsedTimeMillis(queryStats.getElapsedTime().toMillis()).setProcessedRows(queryStats.getRawInputPositions()).setProcessedBytes(queryStats.getRawInputDataSize().toBytes()).setPeakMemoryBytes(queryStats.getPeakUserMemoryReservation().toBytes()).setSpilledBytes(queryStats.getSpilledDataSize().toBytes()).setSpilledReadTimeMillis(queryStats.getSpilledReadTime().toMillis()).setSpilledWriteTimeMillis(queryStats.getSpilledWriteTime().toMillis()).setSpilledNodes(globalUniqueNodes(outputStage, true).size()).setRootStage(toStageStats(outputStage)).setSnapshotStats(toSnapshotStats(queryInfo.getQueryId())).build();
}
Also used : QueryStats(io.prestosql.execution.QueryStats) StageInfo(io.prestosql.execution.StageInfo)

Example 4 with QueryStats

use of io.prestosql.execution.QueryStats in project hetu-core by openlookeng.

the class QueryMonitor method queryCompletedEvent.

public void queryCompletedEvent(QueryInfo queryInfo) {
    QueryStats queryStats = queryInfo.getQueryStats();
    eventListenerManager.queryCompleted(new QueryCompletedEvent(createQueryMetadata(queryInfo), createQueryStatistics(queryInfo), createQueryContext(queryInfo.getSession(), queryInfo.getResourceGroupId()), getQueryIOMetadata(queryInfo), createQueryFailureInfo(queryInfo.getFailureInfo(), queryInfo.getOutputStage()), queryInfo.getWarnings(), ofEpochMilli(queryStats.getCreateTime().getMillis()), ofEpochMilli(queryStats.getExecutionStartTime().getMillis()), ofEpochMilli(queryStats.getEndTime() != null ? queryStats.getEndTime().getMillis() : 0)));
    logQueryTimeline(queryInfo);
}
Also used : QueryStats(io.prestosql.execution.QueryStats) QueryCompletedEvent(io.prestosql.spi.eventlistener.QueryCompletedEvent)

Example 5 with QueryStats

use of io.prestosql.execution.QueryStats in project hetu-core by openlookeng.

the class QueryMonitor method createQueryStatistics.

private QueryStatistics createQueryStatistics(QueryInfo queryInfo) {
    ImmutableList.Builder<String> operatorSummaries = ImmutableList.builder();
    for (OperatorStats summary : queryInfo.getQueryStats().getOperatorSummaries()) {
        operatorSummaries.add(operatorStatsCodec.toJson(summary));
    }
    Optional<StatsAndCosts> planNodeStatsAndCosts = queryInfo.getOutputStage().map(StatsAndCosts::create);
    Optional<String> serializedPlanNodeStatsAndCosts = planNodeStatsAndCosts.map(statsAndCostsCodec::toJson);
    QueryStats queryStats = queryInfo.getQueryStats();
    return new QueryStatistics(ofMillis(queryStats.getTotalCpuTime().toMillis()), ofMillis(queryStats.getTotalScheduledTime().toMillis()), ofMillis(queryStats.getQueuedTime().toMillis()), Optional.of(ofMillis(queryStats.getResourceWaitingTime().toMillis())), Optional.of(ofMillis(queryStats.getAnalysisTime().toMillis())), Optional.of(ofMillis(queryStats.getDistributedPlanningTime().toMillis())), queryStats.getPeakUserMemoryReservation().toBytes(), queryStats.getPeakTotalMemoryReservation().toBytes(), queryStats.getPeakTaskUserMemory().toBytes(), queryStats.getPeakTaskTotalMemory().toBytes(), queryStats.getPhysicalInputDataSize().toBytes(), queryStats.getPhysicalInputPositions(), queryStats.getInternalNetworkInputDataSize().toBytes(), queryStats.getInternalNetworkInputPositions(), queryStats.getRawInputDataSize().toBytes(), queryStats.getRawInputPositions(), queryStats.getOutputDataSize().toBytes(), queryStats.getOutputPositions(), queryStats.getLogicalWrittenDataSize().toBytes(), queryStats.getWrittenPositions(), queryStats.getCumulativeUserMemory(), queryStats.getStageGcStatistics(), queryStats.getCompletedDrivers(), queryInfo.isCompleteInfo(), getCpuDistributions(queryInfo), operatorSummaries.build(), serializedPlanNodeStatsAndCosts);
}
Also used : QueryStats(io.prestosql.execution.QueryStats) QueryStatistics(io.prestosql.spi.eventlistener.QueryStatistics) ImmutableList(com.google.common.collect.ImmutableList) StatsAndCosts(io.prestosql.cost.StatsAndCosts) OperatorStats(io.prestosql.operator.OperatorStats)

Aggregations

QueryStats (io.prestosql.execution.QueryStats)13 List (java.util.List)5 Test (org.testng.annotations.Test)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)4 Session (io.prestosql.Session)4 ENABLE_DYNAMIC_FILTERING (io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING)4 JOIN_DISTRIBUTION_TYPE (io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE)4 QualifiedObjectName (io.prestosql.spi.connector.QualifiedObjectName)4 FeaturesConfig (io.prestosql.sql.analyzer.FeaturesConfig)4 MaterializedResult (io.prestosql.testing.MaterializedResult)4 MaterializedRow (io.prestosql.testing.MaterializedRow)4 Assert.assertEquals (io.prestosql.testing.assertions.Assert.assertEquals)4 AbstractTestQueryFramework (io.prestosql.tests.AbstractTestQueryFramework)4 DistributedQueryRunner (io.prestosql.tests.DistributedQueryRunner)4 ResultWithQueryId (io.prestosql.tests.ResultWithQueryId)4 String.format (java.lang.String.format)4 Set (java.util.Set)4 Language (org.intellij.lang.annotations.Language)4 Assert.assertTrue (org.testng.Assert.assertTrue)4