You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by viirya <gi...@git.apache.org> on 2017/08/30 09:03:58 UTC

[GitHub] spark pull request #19085: [SPARK-21534][SQL][PySpark] PickleException when ...

GitHub user viirya opened a pull request:

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

    [SPARK-21534][SQL][PySpark] PickleException when creating dataframe from python row with empty bytearray

    ## What changes were proposed in this pull request?
    
    `PickleException` is thrown when creating dataframe from python row with empty bytearray
    
        spark.createDataFrame(spark.sql("select unhex('') as xx").rdd.map(lambda x: {"abc": x.xx})).show()
    
        net.razorvine.pickle.PickleException: invalid pickle data for bytearray; expected 1 or 2 args, got 0
        	at net.razorvine.pickle.objects.ByteArrayConstructor.construct(ByteArrayConstructor.java
            ...
    
    `ByteArrayConstructor` doesn't deal with empty byte array pickled by Python3.
    
    ## How was this patch tested?
    
    Added test.


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

    $ git pull https://github.com/viirya/spark-1 SPARK-21534

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

    https://github.com/apache/spark/pull/19085.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 #19085
    
----
commit a362d6be80cb96e9a29b452e3c97a7191a30b55b
Author: Liang-Chi Hsieh <vi...@gmail.com>
Date:   2017-08-30T08:59:47Z

    Add custom ByteArrayConstructor to unpickle empty byte array.

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #19085: [SPARK-21534][SQL][PySpark] PickleException when ...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19085#discussion_r136092600
  
    --- Diff: core/src/main/scala/org/apache/spark/api/python/SerDeUtil.scala ---
    @@ -35,6 +35,16 @@ import org.apache.spark.rdd.RDD
     
     /** Utilities for serialization / deserialization between Python and Java, using Pickle. */
     private[spark] object SerDeUtil extends Logging {
    +  class ByteArrayConstructor extends net.razorvine.pickle.objects.ByteArrayConstructor {
    +    override def construct(args: Array[Object]): Object = {
    +      // Deal with an empty byte array pickled by Python 3.
    +      if (args.length == 0) {
    +        Array.empty[Byte]
    --- End diff --
    
    nit: use `Array.emptyByteArray`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    Thanks @HyukjinKwon 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/81269/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #19085: [SPARK-21534][SQL][PySpark] PickleException when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19085#discussion_r136081750
  
    --- Diff: core/src/main/scala/org/apache/spark/api/python/SerDeUtil.scala ---
    @@ -35,6 +35,16 @@ import org.apache.spark.rdd.RDD
     
     /** Utilities for serialization / deserialization between Python and Java, using Pickle. */
     private[spark] object SerDeUtil extends Logging {
    +  class ByteArrayConstructor extends net.razorvine.pickle.objects.ByteArrayConstructor {
    +    override def construct(args: Array[Object]): Object = {
    +      // Deal with an empty byte array pickled by Python 3.
    +      if (args.length == 0) {
    --- End diff --
    
    I see. It looks quite straightforward.  I checked in Python 3:
    
    ```
    >>> import pickle
    >>> import pickletools
    >>> print(pickletools.dis(pickle.dumps(bytearray())))
        0: \x80 PROTO      3
        2: c    GLOBAL     'builtins bytearray'
       22: q    BINPUT     0
       24: )    EMPTY_TUPLE
       25: R    REDUCE
       26: q    BINPUT     1
       28: .    STOP
    ```
    
    which, up to my knowledge, gives new object[0] for `args`. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #19085: [SPARK-21534][SQL][PySpark] PickleException when ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #19085: [SPARK-21534][SQL][PySpark] PickleException when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19085#discussion_r136084894
  
    --- Diff: core/src/main/scala/org/apache/spark/api/python/SerDeUtil.scala ---
    @@ -35,6 +35,16 @@ import org.apache.spark.rdd.RDD
     
     /** Utilities for serialization / deserialization between Python and Java, using Pickle. */
     private[spark] object SerDeUtil extends Logging {
    +  class ByteArrayConstructor extends net.razorvine.pickle.objects.ByteArrayConstructor {
    +    override def construct(args: Array[Object]): Object = {
    +      // Deal with an empty byte array pickled by Python 3.
    +      if (args.length == 0) {
    --- End diff --
    
    I also checked `pickle.dumps(..., protocol=0 - 4)` just in case.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    **[Test build #81253 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81253/testReport)** for PR 19085 at commit [`a362d6b`](https://github.com/apache/spark/commit/a362d6be80cb96e9a29b452e3c97a7191a30b55b).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `  class ByteArrayConstructor extends net.razorvine.pickle.objects.ByteArrayConstructor `


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #19085: [SPARK-21534][SQL][PySpark] PickleException when ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19085#discussion_r136216872
  
    --- Diff: core/src/main/scala/org/apache/spark/api/python/SerDeUtil.scala ---
    @@ -35,6 +35,16 @@ import org.apache.spark.rdd.RDD
     
     /** Utilities for serialization / deserialization between Python and Java, using Pickle. */
     private[spark] object SerDeUtil extends Logging {
    +  class ByteArrayConstructor extends net.razorvine.pickle.objects.ByteArrayConstructor {
    +    override def construct(args: Array[Object]): Object = {
    +      // Deal with an empty byte array pickled by Python 3.
    +      if (args.length == 0) {
    +        Array.empty[Byte]
    --- End diff --
    
    Ok.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/81253/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    Merged to master.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    **[Test build #81269 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81269/testReport)** for PR 19085 at commit [`c7dda23`](https://github.com/apache/spark/commit/c7dda2321e9d4f2d01d6f933943816ade719b299).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #19085: [SPARK-21534][SQL][PySpark] PickleException when ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19085#discussion_r136216859
  
    --- Diff: python/pyspark/sql/tests.py ---
    @@ -2480,6 +2480,11 @@ def assertCollectSuccess(typecode, value):
                     a = array.array(t)
                     self.spark.createDataFrame([Row(myarray=a)]).collect()
     
    +    # test for SPARK-21534
    +    def test_empty_bytearray(self):
    +        rdd = self.spark.sql("select unhex('') as xx").rdd.map(lambda x: {"abc": x.xx})
    +        self.spark.createDataFrame(rdd).collect()
    --- End diff --
    
    Yes. Added.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    **[Test build #81269 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81269/testReport)** for PR 19085 at commit [`c7dda23`](https://github.com/apache/spark/commit/c7dda2321e9d4f2d01d6f933943816ade719b299).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    For me, it takes a while to double check this. Will try to help double check within this week.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #19085: [SPARK-21534][SQL][PySpark] PickleException when ...

Posted by ueshin <gi...@git.apache.org>.
Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19085#discussion_r136093307
  
    --- Diff: python/pyspark/sql/tests.py ---
    @@ -2480,6 +2480,11 @@ def assertCollectSuccess(typecode, value):
                     a = array.array(t)
                     self.spark.createDataFrame([Row(myarray=a)]).collect()
     
    +    # test for SPARK-21534
    +    def test_empty_bytearray(self):
    +        rdd = self.spark.sql("select unhex('') as xx").rdd.map(lambda x: {"abc": x.xx})
    +        self.spark.createDataFrame(rdd).collect()
    --- End diff --
    
    How about reusing a test `SQLTests.test_BinaryType_serialization` by adding `bytearray()`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    cc @HyukjinKwon 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    LGTM
    
    @ueshin, could you double check this one when you have some time?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #19085: [SPARK-21534][SQL][PySpark] PickleException when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/19085
  
    **[Test build #81253 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/81253/testReport)** for PR 19085 at commit [`a362d6b`](https://github.com/apache/spark/commit/a362d6be80cb96e9a29b452e3c97a7191a30b55b).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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