[SPARK-4244] [SQL] Workaround for Hive Generic UDFs with constant object inspector parameter

Query `SELECT named_struct(lower("AA"), "12", lower("Bb"), "13") FROM src LIMIT 1` will throw exception, some of the Hive Generic UDF/UDAF requires the input object inspector is `ConstantObjectInspector`, however, we won't get that before the expression optimization executed. (Constant Folding).

This PR is a work around to fix this. (As ideally, the `output` of LogicalPlan should be identical before and after Optimization).
Yes, this is valid in Hive. And you're right, I will try your suggestion, it seems more reasonable.