diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java index 798fb2af43a8..7824550338e4 100644 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/PinotBrokerPageSource.java @@ -154,6 +154,11 @@ public long getMemoryUsage() return 0; } + @Override + public Metrics getMetrics() { + return new Metrics(pinotClient.getMetrics(session, query)); + } + @Override public void close() {} } diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java index 4f33a06d116e..2dbc58a879b7 100755 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java @@ -588,6 +588,19 @@ public Iterator createResultIterator(ConnectorSession session, return fromResultTable(response, columnHandles, query.getGroupByClauses()); } + public Map> getMetrics(ConnectorSession session, PinotQueryInfo query) + { + BrokerResponseNative response = submitBrokerQueryJson(session, query); + Map> metrics = ImmutableMap.of( + "numDocsScanned", new LongCount(response.getNumDocsScanned()), + "numSegmentsQueried", new LongCount(response.getNumSegmentsQueried()), + "totalDocs", new LongCount(response.getTotalDocs()), + "numSegmentsProcessed", new LongCount(response.getNumSegmentsProcessed()), + "numSegmentsMatched", new LongCount(response.getNumSegmentsMatched()), + ); + return metrics; + } + @VisibleForTesting public static ResultsIterator fromResultTable(BrokerResponseNative brokerResponse, List columnHandles, int groupByClauses) {