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

Hyukjin Kwon updated SPARK-22978:
---------------------------------
    Summary: Register Scalar Vectorized UDFs for SQL Statement  (was: Register 
Vectorized UDFs for SQL Statement)

> Register Scalar 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
>            Priority: Major
>             Fix For: 2.3.0
>
>
> 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
(v7.6.3#76005)

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

Reply via email to