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

This is just a prototype. Kinda ugly, doesn't properly connect with the config system yet, and have no test.