[SPARK-3855][SQL] Preserve the result attribute of python UDFs though transformations

In the current implementation it was possible for the reference to change after analysis.