diff --git a/client/trino-client/src/main/java/io/trino/client/StatementStats.java b/client/trino-client/src/main/java/io/trino/client/StatementStats.java index 415b07d2c03a..d4a68eb62788 100644 --- a/client/trino-client/src/main/java/io/trino/client/StatementStats.java +++ b/client/trino-client/src/main/java/io/trino/client/StatementStats.java @@ -43,6 +43,7 @@ public class StatementStats private final long queuedTimeMillis; private final long elapsedTimeMillis; private final long finishingTimeMillis; + private final long physicalInputTimeMillis; private final long processedRows; private final long processedBytes; private final long physicalInputBytes; @@ -71,6 +72,7 @@ public StatementStats( @JsonProperty("queuedTimeMillis") long queuedTimeMillis, @JsonProperty("elapsedTimeMillis") long elapsedTimeMillis, @JsonProperty("finishingTimeMillis") long finishingTimeMillis, + @JsonProperty("physicalInputTimeMillis") long physicalInputTimeMillis, @JsonProperty("processedRows") long processedRows, @JsonProperty("processedBytes") long processedBytes, @JsonProperty("physicalInputBytes") long physicalInputBytes, @@ -97,6 +99,7 @@ public StatementStats( this.queuedTimeMillis = queuedTimeMillis; this.elapsedTimeMillis = elapsedTimeMillis; this.finishingTimeMillis = finishingTimeMillis; + this.physicalInputTimeMillis = physicalInputTimeMillis; this.processedRows = processedRows; this.processedBytes = processedBytes; this.physicalInputBytes = physicalInputBytes; @@ -209,6 +212,12 @@ public long getFinishingTimeMillis() return finishingTimeMillis; } + @JsonProperty + public long getPhysicalInputTimeMillis() + { + return physicalInputTimeMillis; + } + @JsonProperty public long getProcessedRows() { @@ -279,6 +288,7 @@ public String toString() .add("queuedTimeMillis", queuedTimeMillis) .add("elapsedTimeMillis", elapsedTimeMillis) .add("finishingTimeMillis", finishingTimeMillis) + .add("physicalInputTimeMillis", physicalInputTimeMillis) .add("processedRows", processedRows) .add("processedBytes", processedBytes) .add("physicalInputBytes", physicalInputBytes) @@ -314,6 +324,7 @@ public static class Builder private long queuedTimeMillis; private long elapsedTimeMillis; private long finishingTimeMillis; + private long physicalInputTimeMillis; private long processedRows; private long processedBytes; private long physicalInputBytes; @@ -427,6 +438,12 @@ public Builder setFinishingTimeMillis(long finishingTimeMillis) return this; } + public Builder setPhysicalInputTimeMillis(long physicalInputTimeMillis) + { + this.physicalInputTimeMillis = physicalInputTimeMillis; + return this; + } + public Builder setProcessedRows(long processedRows) { this.processedRows = processedRows; @@ -495,6 +512,7 @@ public StatementStats build() queuedTimeMillis, elapsedTimeMillis, finishingTimeMillis, + physicalInputTimeMillis, processedRows, processedBytes, physicalInputBytes, diff --git a/client/trino-client/src/test/java/io/trino/client/TestRetry.java b/client/trino-client/src/test/java/io/trino/client/TestRetry.java index d000d2da97b5..3ea7a940e665 100644 --- a/client/trino-client/src/test/java/io/trino/client/TestRetry.java +++ b/client/trino-client/src/test/java/io/trino/client/TestRetry.java @@ -143,7 +143,7 @@ private String newQueryResults(String state) TypedQueryData.of(IntStream.range(0, numRecords) .mapToObj(index -> Stream.of((Object) index, "a").collect(toList())) .collect(toList())), - new StatementStats(state, state.equals("QUEUED"), true, OptionalDouble.of(0), OptionalDouble.of(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null), + new StatementStats(state, state.equals("QUEUED"), true, OptionalDouble.of(0), OptionalDouble.of(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null), null, ImmutableList.of(), null, diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/QueryStats.java b/client/trino-jdbc/src/main/java/io/trino/jdbc/QueryStats.java index cac77f441ca0..9acea4fce352 100644 --- a/client/trino-jdbc/src/main/java/io/trino/jdbc/QueryStats.java +++ b/client/trino-jdbc/src/main/java/io/trino/jdbc/QueryStats.java @@ -39,6 +39,7 @@ public final class QueryStats private final long queuedTimeMillis; private final long elapsedTimeMillis; private final long finishingTimeMillis; + private final long physicalInputTimeMillis; private final long processedRows; private final long processedBytes; private final long peakMemoryBytes; @@ -65,6 +66,7 @@ public QueryStats( long queuedTimeMillis, long elapsedTimeMillis, long finishingTimeMillis, + long physicalInputTimeMillis, long processedRows, long processedBytes, long peakMemoryBytes, @@ -90,6 +92,7 @@ public QueryStats( this.queuedTimeMillis = queuedTimeMillis; this.elapsedTimeMillis = elapsedTimeMillis; this.finishingTimeMillis = finishingTimeMillis; + this.physicalInputTimeMillis = physicalInputTimeMillis; this.processedRows = processedRows; this.processedBytes = processedBytes; this.peakMemoryBytes = peakMemoryBytes; @@ -119,6 +122,7 @@ static QueryStats create(String queryId, StatementStats stats) stats.getQueuedTimeMillis(), stats.getElapsedTimeMillis(), stats.getFinishingTimeMillis(), + stats.getPhysicalInputTimeMillis(), stats.getProcessedRows(), stats.getProcessedBytes(), stats.getPeakMemoryBytes(), @@ -213,6 +217,11 @@ public long getFinishingTimeMillis() return finishingTimeMillis; } + public long getPhysicalInputTimeMillis() + { + return physicalInputTimeMillis; + } + public long getProcessedRows() { return processedRows; diff --git a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestAsyncResultIterator.java b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestAsyncResultIterator.java index 7aeaddedebd4..963c782f934a 100644 --- a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestAsyncResultIterator.java +++ b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestAsyncResultIterator.java @@ -337,6 +337,7 @@ public StatementStats getStats() 100, 100, 100, + 100, StageStats.builder() .setStageId("id") .setDone(false) diff --git a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestProgressMonitor.java b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestProgressMonitor.java index 09d92c170579..76d7ff7e5955 100644 --- a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestProgressMonitor.java +++ b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestProgressMonitor.java @@ -99,7 +99,7 @@ private String newQueryResults(Integer partialCancelId, Integer nextUriId, List< nextUriId == null ? null : server.url(format("/v1/statement/%s/%s", queryId, nextUriId)).uri(), responseColumns, TypedQueryData.of(data), - new StatementStats(state, state.equals("QUEUED"), true, OptionalDouble.of(0), OptionalDouble.of(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null), + new StatementStats(state, state.equals("QUEUED"), true, OptionalDouble.of(0), OptionalDouble.of(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null), null, ImmutableList.of(), null, diff --git a/core/trino-main/src/main/java/io/trino/execution/QueryStateMachine.java b/core/trino-main/src/main/java/io/trino/execution/QueryStateMachine.java index bd2aabb64d62..4b94bbdd1fa7 100644 --- a/core/trino-main/src/main/java/io/trino/execution/QueryStateMachine.java +++ b/core/trino-main/src/main/java/io/trino/execution/QueryStateMachine.java @@ -563,6 +563,7 @@ private BasicQueryStats createBasicQueryStats(BasicStageStats stageStats) stageStats.getTotalScheduledTime(), stageStats.getFailedScheduledTime(), queryStateTimer.getFinishingTime(), + stageStats.getPhysicalInputReadTime(), stageStats.isFullyBlocked(), stageStats.getBlockedReasons(), diff --git a/core/trino-main/src/main/java/io/trino/server/BasicQueryStats.java b/core/trino-main/src/main/java/io/trino/server/BasicQueryStats.java index cfd3378db7b3..b4b485ed5126 100644 --- a/core/trino-main/src/main/java/io/trino/server/BasicQueryStats.java +++ b/core/trino-main/src/main/java/io/trino/server/BasicQueryStats.java @@ -71,6 +71,7 @@ public class BasicQueryStats private final Duration totalScheduledTime; private final Duration failedScheduledTime; private final Duration finishingTime; + private final Duration physicalInputReadTime; private final boolean fullyBlocked; private final Set blockedReasons; @@ -110,6 +111,7 @@ public BasicQueryStats( @JsonProperty("totalScheduledTime") Duration totalScheduledTime, @JsonProperty("failedScheduledTime") Duration failedScheduledTime, @JsonProperty("finishingTime") Duration finishingTime, + @JsonProperty("physicalInputReadTime") Duration physicalInputReadTime, @JsonProperty("fullyBlocked") boolean fullyBlocked, @JsonProperty("blockedReasons") Set blockedReasons, @JsonProperty("progressPercentage") OptionalDouble progressPercentage, @@ -156,6 +158,7 @@ public BasicQueryStats( this.totalScheduledTime = totalScheduledTime; this.failedScheduledTime = failedScheduledTime; this.finishingTime = finishingTime; + this.physicalInputReadTime = physicalInputReadTime; this.fullyBlocked = fullyBlocked; this.blockedReasons = ImmutableSet.copyOf(requireNonNull(blockedReasons, "blockedReasons is null")); @@ -196,6 +199,7 @@ public BasicQueryStats(QueryStats queryStats) queryStats.getTotalScheduledTime(), queryStats.getFailedScheduledTime(), queryStats.getFinishingTime(), + queryStats.getPhysicalInputReadTime(), queryStats.isFullyBlocked(), queryStats.getBlockedReasons(), queryStats.getProgressPercentage(), @@ -236,6 +240,7 @@ public static BasicQueryStats immediateFailureQueryStats() new Duration(0, MILLISECONDS), new Duration(0, MILLISECONDS), new Duration(0, MILLISECONDS), + new Duration(0, MILLISECONDS), false, ImmutableSet.of(), OptionalDouble.empty(), @@ -422,6 +427,12 @@ public Duration getFinishingTime() return finishingTime; } + @JsonProperty + public Duration getPhysicalInputReadTime() + { + return physicalInputReadTime; + } + @JsonProperty public boolean isFullyBlocked() { diff --git a/core/trino-main/src/main/java/io/trino/server/protocol/ProtocolUtil.java b/core/trino-main/src/main/java/io/trino/server/protocol/ProtocolUtil.java index c8997ebe0125..7894c6fb68b8 100644 --- a/core/trino-main/src/main/java/io/trino/server/protocol/ProtocolUtil.java +++ b/core/trino-main/src/main/java/io/trino/server/protocol/ProtocolUtil.java @@ -189,6 +189,7 @@ public static StatementStats toStatementStats(ResultQueryInfo queryInfo) .setQueuedTimeMillis(queryStats.getQueuedTime().toMillis()) .setElapsedTimeMillis(queryStats.getElapsedTime().toMillis()) .setFinishingTimeMillis(queryStats.getFinishingTime().toMillis()) + .setPhysicalInputTimeMillis(queryStats.getPhysicalInputReadTime().toMillis()) .setProcessedRows(queryStats.getRawInputPositions()) .setProcessedBytes(queryStats.getRawInputDataSize().toBytes()) .setPhysicalInputBytes(queryStats.getPhysicalInputDataSize().toBytes()) diff --git a/core/trino-main/src/test/java/io/trino/execution/MockManagedQueryExecution.java b/core/trino-main/src/test/java/io/trino/execution/MockManagedQueryExecution.java index 787e3e00dab7..4029f63085bc 100644 --- a/core/trino-main/src/test/java/io/trino/execution/MockManagedQueryExecution.java +++ b/core/trino-main/src/test/java/io/trino/execution/MockManagedQueryExecution.java @@ -150,6 +150,7 @@ public BasicQueryInfo getBasicQueryInfo() new Duration(24, NANOSECONDS), new Duration(25, NANOSECONDS), new Duration(26, NANOSECONDS), + new Duration(27, NANOSECONDS), false, ImmutableSet.of(), OptionalDouble.empty(), diff --git a/core/trino-main/src/test/java/io/trino/server/protocol/TestQueryDataSerialization.java b/core/trino-main/src/test/java/io/trino/server/protocol/TestQueryDataSerialization.java index 40b8f7797b41..980c9844652a 100644 --- a/core/trino-main/src/test/java/io/trino/server/protocol/TestQueryDataSerialization.java +++ b/core/trino-main/src/test/java/io/trino/server/protocol/TestQueryDataSerialization.java @@ -252,6 +252,7 @@ private String queryResultsJson(String expectedDataField) "queuedTimeMillis": 0, "elapsedTimeMillis": 0, "finishingTimeMillis": 0, + "physicalInputTimeMillis": 0, "processedRows": 0, "processedBytes": 0, "physicalInputBytes": 0, diff --git a/core/trino-main/src/test/java/io/trino/server/protocol/TestQueryResultsSerialization.java b/core/trino-main/src/test/java/io/trino/server/protocol/TestQueryResultsSerialization.java index d1ae9c5cabfa..badc453a165e 100644 --- a/core/trino-main/src/test/java/io/trino/server/protocol/TestQueryResultsSerialization.java +++ b/core/trino-main/src/test/java/io/trino/server/protocol/TestQueryResultsSerialization.java @@ -84,6 +84,7 @@ public void testNullDataSerialization() "queuedTimeMillis" : 0, "elapsedTimeMillis" : 0, "finishingTimeMillis": 0, + "physicalInputTimeMillis": 0, "processedRows" : 0, "processedBytes" : 0, "physicalInputBytes" : 0, @@ -164,6 +165,7 @@ private String queryResultsJson(String expectedDataField) "queuedTimeMillis" : 0, "elapsedTimeMillis" : 0, "finishingTimeMillis": 0, + "physicalInputTimeMillis": 0, "processedRows" : 0, "processedBytes" : 0, "physicalInputBytes" : 0, diff --git a/testing/trino-tests/src/test/java/io/trino/memory/TestClusterMemoryLeakDetector.java b/testing/trino-tests/src/test/java/io/trino/memory/TestClusterMemoryLeakDetector.java index 6c10463a742d..60d923fb3b34 100644 --- a/testing/trino-tests/src/test/java/io/trino/memory/TestClusterMemoryLeakDetector.java +++ b/testing/trino-tests/src/test/java/io/trino/memory/TestClusterMemoryLeakDetector.java @@ -109,6 +109,7 @@ private static BasicQueryInfo createQueryInfo(String queryId, QueryState state) new Duration(34, MINUTES), new Duration(35, MINUTES), new Duration(36, MINUTES), + new Duration(37, MINUTES), true, ImmutableSet.of(WAITING_FOR_MEMORY), OptionalDouble.of(20),