There seems to be a bug due to
We are converting the group by to a map side group by after only looking at
sorting columns. This can give wrong results if the data is sorted and
bucketed by different columns.
Add some tests for that scenario, verify and fix any issues.