GitHub user viirya opened a pull request:

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

    [SPARK-16062][SQL] Fix bug of Python-only UDTs when MapObjects works on it

    ## What changes were proposed in this pull request?
    
    `RowEncoder` will use `PythonUserDefinedType.sqlType` for its deserializer 
expression. If the sql type is `ArrayType`, we will have `MapObjects` working 
on it. But `MapObjects` doesn't consider `PythonUserDefinedType` as its input 
data type. It causes error like:
    
        import pyspark.sql.group
        from pyspark.sql.tests import PythonOnlyPoint, PythonOnlyUDT
        from pyspark.sql.types import *
    
        schema = StructType().add("key", LongType()).add("val", PythonOnlyUDT())
        df = spark.createDataFrame([(i % 3, PythonOnlyPoint(float(i), 
float(i))) for i in range(10)], schema=schema)
        df.show()
    
        File "/home/spark/python/lib/py4j-0.10.1-src.zip/py4j/protocol.py", 
line 312, in get_return_value py4j.protocol.Py4JJavaError: An error occurred 
while calling o36.showString.
        : java.lang.RuntimeException: Error while decoding: scala.MatchError: 
org.apache.spark.sql.types.PythonUserDefinedType@f4ceede8 (of class 
org.apache.spark.sql.types.PythonUserDefinedType)
        ...
    
    
    
    ## How was this patch tested?
    PySpark's sql tests.
    


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

    $ git pull https://github.com/viirya/spark-1 fix-pyudt

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

    https://github.com/apache/spark/pull/13778.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 #13778
    
----
commit f26c8dcf9265db6894484c0eb8255cf6c4683c9e
Author: Liang-Chi Hsieh <[email protected]>
Date:   2016-06-20T06:36:28Z

    Fix bug of Python-only UDTs when MapObjects works on it.

----


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to