Add merge, partition and groupBy methods to Relation.

Also add equals/hashCode to Relation.

Also add a basic test for groupBy.