HyukjinKwon opened a new pull request, #50201: URL: https://github.com/apache/spark/pull/50201
### What changes were proposed in this pull request? This PR proposes to raise a proper error instead of `assert` when the returned Arrow schema is mismatched with specified SQL return type. Users can see this error, and this is not an internal error mssage. ### Why are the changes needed? ```python import pandas as pd from pyspark.sql.functions import pandas_udf @pandas_udf("int") def func(s: pd.Series) -> pd.Series: return pd.Series([1.0] * len(s)) spark.range(1).select(func("id")).show() ``` Now it throws ``` org.apache.spark.SparkException: [ARROW_TYPE_MISMATCH] Invalid schema from pandas_udf(): expected IntegerType, got IntegerType. SQLSTATE: 42K0G at org.apache.spark.sql.errors.QueryExecutionErrors$.arrowDataTypeMismatchError(QueryExecutionErrors.scala:857) at org.apache.spark.sql.execution.python.ArrowEvalPythonEvaluatorFactory.$anonfun$evaluate$2(ArrowEvalPythonExec.scala:131) at scala.collection.Iterator$$anon$10.nextCur(Iterator.scala:594) ``` ### Does this PR introduce _any_ user-facing change? Yes, it changes the user-facing error mesasge. ### How was this patch tested? Manually tested as described above. ### 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