[SPARK-4785] [SQL] Support udf instance ser/de after initialization

UDF contract change in Hive 0.13.1. In Hive 0.12.0, it's always safe to construct and initialize a fresh UDF object on worker side, while in Hive 0.13.1, UDF objects should only be initialized on driver side and then serialized to the worker side. We provide the ability to serialize the initialized UDF instance and deserialize them cross process boundary.
Instead of calling `Utilities.deserializePlan`, how about mimic `Utilities.de/serializeObjectByKryo` methods here? Those two functions are private but very simple, the advantage is that we don't need the expensive `HiveConf` instantiation here.