First implementation of partitionBy transformation