marcuslin123 opened a new pull request, #58026: URL: https://github.com/apache/spark/pull/58026
### What changes were proposed in this pull request? This PR gives each `HiveGenericUDFEvaluator` an independent copy of the cached GenericUDF. The clone helper is adapted from Hive while avoiding `FunctionRegistry` initialization, and preserves bridge, macro, and SettableUDF state. ### Why are the changes needed? Optimizer-created copies of a Hive GenericUDF expression can otherwise share one mutable UDF instance. Initializing copies with different object inspectors can overwrite evaluator state, producing wrong results or a ClassCastException. ### Does this PR introduce _any_ user-facing change? Yes. Queries using optimizer-duplicated Hive GenericUDF expressions now evaluate with isolated UDF state instead of potentially returning incorrect results or failing. ### How was this patch tested? Added `SPARK-58792: Hive Generic UDF evaluator copies use isolated functions`, which initializes two evaluators from one wrapper with constant and non-constant inspectors and verifies they keep distinct function instances and results. Ran: ``` build/sbt 'hive/testOnly org.apache.spark.sql.hive.execution.HiveUDFSuite -- -z "SPARK-58792"'\n```\n\n### Was this patch authored or co-authored using generative AI tooling?\n\nGenerated-by: Codex for code assistance. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
