Skip to content

Commit

Permalink
Add physicalInputTimeMillis to io.trino.jdbc.QueryStats
Browse files Browse the repository at this point in the history
  • Loading branch information
raunaqmorarka committed Dec 31, 2024
1 parent 41d08f6 commit 4022bf1
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -209,6 +212,12 @@ public long getFinishingTimeMillis()
return finishingTimeMillis;
}

@JsonProperty
public long getPhysicalInputTimeMillis()
{
return physicalInputTimeMillis;
}

@JsonProperty
public long getProcessedRows()
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -495,6 +512,7 @@ public StatementStats build()
queuedTimeMillis,
elapsedTimeMillis,
finishingTimeMillis,
physicalInputTimeMillis,
processedRows,
processedBytes,
physicalInputBytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions client/trino-jdbc/src/main/java/io/trino/jdbc/QueryStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -65,6 +66,7 @@ public QueryStats(
long queuedTimeMillis,
long elapsedTimeMillis,
long finishingTimeMillis,
long physicalInputTimeMillis,
long processedRows,
long processedBytes,
long peakMemoryBytes,
Expand All @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -213,6 +217,11 @@ public long getFinishingTimeMillis()
return finishingTimeMillis;
}

public long getPhysicalInputTimeMillis()
{
return physicalInputTimeMillis;
}

public long getProcessedRows()
{
return processedRows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ public StatementStats getStats()
100,
100,
100,
100,
StageStats.builder()
.setStageId("id")
.setDone(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ private BasicQueryStats createBasicQueryStats(BasicStageStats stageStats)
stageStats.getTotalScheduledTime(),
stageStats.getFailedScheduledTime(),
queryStateTimer.getFinishingTime(),
stageStats.getPhysicalInputReadTime(),

stageStats.isFullyBlocked(),
stageStats.getBlockedReasons(),
Expand Down
11 changes: 11 additions & 0 deletions core/trino-main/src/main/java/io/trino/server/BasicQueryStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlockedReason> blockedReasons;
Expand Down Expand Up @@ -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<BlockedReason> blockedReasons,
@JsonProperty("progressPercentage") OptionalDouble progressPercentage,
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -196,6 +199,7 @@ public BasicQueryStats(QueryStats queryStats)
queryStats.getTotalScheduledTime(),
queryStats.getFailedScheduledTime(),
queryStats.getFinishingTime(),
queryStats.getPhysicalInputReadTime(),
queryStats.isFullyBlocked(),
queryStats.getBlockedReasons(),
queryStats.getProgressPercentage(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -422,6 +427,12 @@ public Duration getFinishingTime()
return finishingTime;
}

@JsonProperty
public Duration getPhysicalInputReadTime()
{
return physicalInputReadTime;
}

@JsonProperty
public boolean isFullyBlocked()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ private String queryResultsJson(String expectedDataField)
"queuedTimeMillis": 0,
"elapsedTimeMillis": 0,
"finishingTimeMillis": 0,
"physicalInputTimeMillis": 0,
"processedRows": 0,
"processedBytes": 0,
"physicalInputBytes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void testNullDataSerialization()
"queuedTimeMillis" : 0,
"elapsedTimeMillis" : 0,
"finishingTimeMillis": 0,
"physicalInputTimeMillis": 0,
"processedRows" : 0,
"processedBytes" : 0,
"physicalInputBytes" : 0,
Expand Down Expand Up @@ -164,6 +165,7 @@ private String queryResultsJson(String expectedDataField)
"queuedTimeMillis" : 0,
"elapsedTimeMillis" : 0,
"finishingTimeMillis": 0,
"physicalInputTimeMillis": 0,
"processedRows" : 0,
"processedBytes" : 0,
"physicalInputBytes" : 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 4022bf1

Please sign in to comment.