Transform Query with partitioning