[SPARK-4244] [SQL] Support Hive Generic UDFs with constant object inspector parameters

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).
I don't really understand all the contracts here, so please correct me if I'm missing something, but why does the return type have to be a Constant?  It seems like if a UDF is deterministic it should be safe to fold as long as its children are foldable too, independent of the type of inspector it returns.