You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (Jira)" <ji...@apache.org> on 2022/01/13 04:01:00 UTC

[jira] [Resolved] (SPARK-37885) Allow pandas_udf to take type annotations with future annotations enabled

     [ https://issues.apache.org/jira/browse/SPARK-37885?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hyukjin Kwon resolved SPARK-37885.
----------------------------------
    Fix Version/s: 3.3.0
       Resolution: Fixed

Issue resolved by pull request 35184
[https://github.com/apache/spark/pull/35184]

> Allow pandas_udf to take type annotations with future annotations enabled
> -------------------------------------------------------------------------
>
>                 Key: SPARK-37885
>                 URL: https://issues.apache.org/jira/browse/SPARK-37885
>             Project: Spark
>          Issue Type: Improvement
>          Components: PySpark
>    Affects Versions: 3.3.0
>            Reporter: Takuya Ueshin
>            Assignee: Takuya Ueshin
>            Priority: Major
>             Fix For: 3.3.0
>
>
> When using {{{}from __future__ import annotations{}}}, the type hints will be all strings, then pandas UDF type inference won't work as follows:
> {code:python}
> >>> from __future__ import annotations
> >>> from typing import Union
> >>> import pandas as pd
> >>> from pyspark.sql.functions import pandas_udf
> >>> @pandas_udf("long")
> ... def plus_one(v: Union[pd.Series, pd.DataFrame]) -> pd.Series:
> ...     return v + 1
> Traceback (most recent call last):
> ...
> NotImplementedError: Unsupported signature: (v: 'Union[pd.Series, pd.DataFrame]') -> 'pd.Series'.
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org