GitHub user davies opened a pull request:

    https://github.com/apache/spark/pull/12014

    [SPARK-14125] [SQL] [PYSPARK] Support chained Python UDFs

    ## What changes were proposed in this pull request?
    
    This PR brings the support for chained Python UDFs, for example
    
    ```sql
    select udf1(udf2(a))
    select udf1(udf2(a) + 3)
    select udf1(udf2(a) + udf3(b)) 
    ```
    
    Also directly chained Python UDFs are put in single batch of Python UDFs, 
others may require multiple batches.
    
    For example,
    ```python
    >>> sqlContext.sql("select double(double(1))").explain()
    == Physical Plan ==
    WholeStageCodegen
    :  +- Project [pythonUDF#10 AS double(double(1))#9]
    :     +- INPUT
    +- !BatchPythonEvaluation double(double(1)), [pythonUDF#10]
       +- Scan OneRowRelation[]
    >>> sqlContext.sql("select double(double(1) + double(2))").explain()
    == Physical Plan ==
    WholeStageCodegen
    :  +- Project [pythonUDF#19 AS double((double(1) + double(2)))#16]
    :     +- INPUT
    +- !BatchPythonEvaluation double((pythonUDF#17 + pythonUDF#18)), 
[pythonUDF#17,pythonUDF#18,pythonUDF#19]
       +- !BatchPythonEvaluation double(2), [pythonUDF#17,pythonUDF#18]
          +- !BatchPythonEvaluation double(1), [pythonUDF#17]
             +- Scan OneRowRelation[]
    ```
    
    ## How was this patch tested?
    
    Added new unit tests for chained UDFs.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/davies/spark py_udfs

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/12014.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #12014
    
----
commit d63ec844576bfe47fc0b78ddba4693e4210bd595
Author: Davies Liu <dav...@databricks.com>
Date:   2016-03-28T20:21:07Z

    use row based function for Python UDF

commit 024a82236f09a6b6ec09aeb41ca161e6c7c72dda
Author: Davies Liu <dav...@databricks.com>
Date:   2016-03-28T20:59:35Z

    support chained Python UDFs

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to