[WIP][SPARK-2554][SQL] CountDistinct and SumDistinct should do partial aggregation

That is correct, the planner will not use code generation unless the type of the count distinct is a single int or long value.  Good idea though, I've added the check.