presto-main/src/main/java/io/prestosql/connector/system/QuerySystemTable.java/QuerySystemTable/cursor
class QuerySystemTable:    @Override
    public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint)
    {
        checkState(dispatchManager.isPresent(), "Query system table can return results only on coordinator");
        Builder table = InMemoryRecordSet.builder(QUERY_TABLE);
        for (BasicQueryInfo queryInfo : dispatchManager.get().getQueries()) {
            Optional<QueryInfo> fullQueryInfo = dispatchManager.get().getFullQueryInfo(queryInfo.getQueryId());
            if (!fullQueryInfo.isPresent()) {
                continue;
            }
            QueryStats queryStats = fullQueryInfo.get().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.getPlanningTime()),

                    toTimeStamp(queryStats.getCreateTime()),
                    toTimeStamp(queryStats.getExecutionStartTime()),
                    toTimeStamp(queryStats.getLastHeartbeat()),
                    toTimeStamp(queryStats.getEndTime()));
        }
        return table.build().cursor();
    }