You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Shuheng Ma (Jira)" <ji...@apache.org> on 2026/10/16 19:16:00 UTC
[jira] [Commented] (SPARK-39142) Type overloads in `pandas_udf`
[ https://issues.apache.org/jira/browse/SPARK-39142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18127957#comment-18127957 ]
Shuheng Ma commented on SPARK-39142:
------------------------------------
I'm working on this, PR: https://github.com/apache/spark/pull/59558
It continues wayneguow's https://github.com/apache/spark/pull/39974, an earlier version of which was approved before it was closed as stale; wayneguow agreed to the takeover, and the original commits are kept first. The PR adds the {{pandas_udf}} overloads without {{functionType}}, so {{@pandas_udf("long")}} and {{@pandas_udf(returnType=LongType())}} type-check with mypy 1.19.1 (on master they fail with call-overload). It also removes the {{type: ignore}} comments that Spark's own code and docs examples needed for them. Thanks to Philip Kahn for the report and to wayneguow for the original PR!
> Type overloads in `pandas_udf`
> -------------------------------
>
> Key: SPARK-39142
> URL: https://issues.apache.org/jira/browse/SPARK-39142
> Project: Spark
> Issue Type: Bug
> Components: PySpark
> Affects Versions: 3.2.1
> Reporter: Philip Kahn
> Priority: Minor
> Labels: pull-request-available
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> It seems that the `returnType` in the type overloads for `pandas_udf` never specify a generic for PySpark SQL types or explicitly list those types:
>
> [https://github.com/apache/spark/blob/f84018a4810867afa84658fec76494aaae6d57fc/python/pyspark/sql/pandas/functions.pyi]
>
> This results in static type checkers flagging the type of the decorated functions (and their parameters) as incorrect, see [https://github.com/microsoft/pylance-release/issues/2789] as an example.
>
> For someone familiar with the code base, this should be a very fast patch.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org