[SPARK-4648][SQL] Support COALESCE function in Spark SQL and Hive QL

Support Coalesce function in Spark SQL.
Support type widening in Coalesce function.
And replace Coalesce UDF in Spark Hive with local Coalesce function since it is memory efficient and faster.
Nit: Move that into the pattern matching guard?