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

Xiao Li updated SPARK-22978:
----------------------------
    Description: 
Capable of registering vectorized UDFs and then use it in SQL statement.

For example,
{noformat}
>>> import random
>>> from pyspark.sql.types import IntegerType
>>> from pyspark.sql.functions import pandas_udf
>>> random_pandas_udf = pandas_udf(
...     lambda x: random.randint(0, 100) + x, IntegerType())
...     .asNondeterministic()  # doctest: +SKIP
>>> _ = spark.catalog.registerFunction(
...     "random_pandas_udf", random_pandas_udf, IntegerType())  # doctest: +SKIP
>>> spark.sql("SELECT random_pandas_udf(2)").collect()  # doctest: +SKIP
[Row(random_pandas_udf(2)=84)]
{noformat}

  was:Capable of registering vectorized UDFs and then use it in SQL statement


> Register Vectorized UDFs for SQL Statement
> ------------------------------------------
>
>                 Key: SPARK-22978
>                 URL: https://issues.apache.org/jira/browse/SPARK-22978
>             Project: Spark
>          Issue Type: Sub-task
>          Components: PySpark
>    Affects Versions: 2.3.0
>            Reporter: Xiao Li
>            Assignee: Xiao Li
>
> Capable of registering vectorized UDFs and then use it in SQL statement.
> For example,
> {noformat}
> >>> import random
> >>> from pyspark.sql.types import IntegerType
> >>> from pyspark.sql.functions import pandas_udf
> >>> random_pandas_udf = pandas_udf(
> ...     lambda x: random.randint(0, 100) + x, IntegerType())
> ...     .asNondeterministic()  # doctest: +SKIP
> >>> _ = spark.catalog.registerFunction(
> ...     "random_pandas_udf", random_pandas_udf, IntegerType())  # doctest: 
> +SKIP
> >>> spark.sql("SELECT random_pandas_udf(2)").collect()  # doctest: +SKIP
> [Row(random_pandas_udf(2)=84)]
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to