Found in stress test: https://gist.github.com/alesapin/5cd6b8901488a1f170d5ef389900a534
Report: https://s3.amazonaws.com/clickhouse-test-reports/31158/7fb9a42b119b6c3eba1784caaabde51c1ded3384/stress_tests__debug__actions_.html
{
    const auto & info = chunk.getChunkInfo();
    if (!info)
        throw Exception("Chunk info was not set for chunk in SortingAggregatedTransform.", ErrorCodes::LOGICAL_ERROR);
    const auto * agg_info = typeid_cast<const AggregatedChunkInfo *>(info.get());
    if (!agg_info)
        throw Exception("Chunk should have AggregatedChunkInfo in SortingAggregatedTransform.", ErrorCodes::LOGICAL_ERROR);
    Int32 bucket = agg_info->bucket_num;
    bool is_overflows = agg_info->is_overflows;
    if (is_overflows)
        overflow_chunk = std::move(chunk);
    else
    {
        if (chunks[bucket])
            throw Exception("SortingAggregatedTransform already got bucket with number " + toString(bucket),
                    ErrorCodes::LOGICAL_ERROR);
        chunks[bucket] = std::move(chunk);
        last_bucket_number[from_input] = bucket;
    }
}
IProcessor::Status SortingAggregatedTransform::prepare()