ueshin opened a new pull request, #50341: URL: https://github.com/apache/spark/pull/50341
### What changes were proposed in this pull request? Fixes `ExtractPythonUDFs` to check the chained UDF input types for fallback. ### Why are the changes needed? Currently the fallback of Arrow-optimized Python UDF to non Arrow for the case the UDF has UDT input/output only works with not chained UDFs because it checks only the last UDFs. For example: ```py from pyspark.sql.functions import udf from pyspark.sql.types import * from pyspark.testing.sqlutils import ExamplePoint, ExamplePointUDT row = Row( label=1.0, point=ExamplePoint(1.0, 2.0), ) df = spark.createDataFrame([row]) @udf(returnType=DoubleType(), useArrow=True) def udtInDoubleOut(e): return e.y @udf(returnType=DoubleType(), useArrow=True) def doubleInDoubleOut(d): return d * 100.0 df.select(doubleInDoubleOut(udtInDoubleOut(df.point))).show() ``` This doesn't fallback to non Arrow and fails with: ``` pyspark.errors.exceptions.captured.PythonException: An exception was thrown from the Python worker. Please see the stack trace below. Traceback (most recent call last): ... AttributeError: 'list' object has no attribute 'y' ``` ### Does this PR introduce _any_ user-facing change? Yes, the fallback will work with chained UDFs, too. ### How was this patch tested? Added the related tests. ### Was this patch authored or co-authored using generative AI tooling? No. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org