[FLINK-984] Compiler tests for distinct(). Adopted the old code from @markus-h

The code originates from https://github.com/apache/incubator-flink/pull/61.
The pull request also contained code to add POJO support to the distinct() operator. This has already been implemented in earlier work