[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).
Ah, sorry now I read the PR description more carefully and I think I understand.  However, this now seems kind of hacky to me.  We are now leaving the analysis phase with a tree that isn't actually valid and then hoping that constant folding is going to fix things down the road.  This breaks the contract that it should be safe to inspect dataTypes once analysis is done.

Is this query valid in Hive?  If so, I'd almost rather add more rules/logic to analysis (maybe we need to have a notion of "resolved" for HiveUDFs and attempt to constant fold them if they aren't resolved?  What do you think?