[SPARK-1412][SQL] Disable partial aggregation automatically when reduction factor is low - WIP

This avoids building up an expensive hash map if partial aggregation does not result in data size reduction.

Just a prototype. Kinda ugly, doesn't properly connect with the config system yet, and have no test.