[SPARK-3230][SQL] Fix udfs that return structs

We need to convert the case classes into Rows.