public QueryResult<R> getOnlyPartitionResult() {
        final List<QueryResult<R>> nonempty =
            partitionResults
                .values()
                .stream()
                .filter(QueryResult::isSuccess)
                .filter(r -> r.getResult() != null)
                .collect(Collectors.toList());

        if (nonempty.size() > 1) {
            throw new IllegalArgumentException(
                "The query did not return exactly one partition result: " + partitionResults
            );
        } else {
            return nonempty.isEmpty() ? null : nonempty.get(0);
        }
    }
For queries that are expected to match records in only one partition, returns the result.

@throws IllegalArgumentException if the results are not for exactly one partition.
streams/src/main/java/org/apache/kafka/streams/query/StateQueryResult.java