Backport of #735: Fix identity groupBy with type mappings.

Review by @cvogt