You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by maropu <gi...@git.apache.org> on 2017/03/19 11:36:13 UTC

[GitHub] spark pull request #17347: [SPARK-19980][SQL] Add NULL checks in Bean serial...

GitHub user maropu opened a pull request:

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

    [SPARK-19980][SQL] Add NULL checks in Bean serializer

    ## What changes were proposed in this pull request?
    A Bean serializer in `ExpressionEncoder`  could change values when Beans having NULL. A concrete example is as follows;
    ```
    scala> :paste
    class Outer extends Serializable {
      private var cls: Inner = _
      def setCls(c: Inner): Unit = cls = c
      def getCls(): Inner = cls
    }
    
    class Inner extends Serializable {
      private var str: String = _
      def setStr(s: String): Unit = str = str
      def getStr(): String = str
    }
    
    scala> Seq("""{"cls":null}""", """{"cls": {"str":null}}""").toDF().write.text("data")
    scala> val encoder = Encoders.bean(classOf[Outer])
    scala> val schema = encoder.schema
    scala> val df = spark.read.schema(schema).json("data").as[Outer](encoder)
    scala> df.show
    +------+
    |   cls|
    +------+
    |[null]|
    |  null|
    +------+
    
    scala> df.map(x => x)(encoder).show()
    +------+
    |   cls|
    +------+
    |[null]|
    |[null]|     // <-- Value changed
    +------+
    ```
    
    This is because the Bean serializer does not have the NULL-check expressions that the serializer of Scala's product types has. Actually, this value change does not happen in Scala's product types; 
    
    ```
    scala> :paste
    case class Outer(cls: Inner)
    case class Inner(str: String)
    
    scala> val encoder = Encoders.product[Outer]
    scala> val schema = encoder.schema
    scala> val df = spark.read.schema(schema).json("data").as[Outer](encoder)
    scala> df.show
    +------+
    |   cls|
    +------+
    |[null]|
    |  null|
    +------+
    
    scala> df.map(x => x)(encoder).show()
    +------+
    |   cls|
    +------+
    |[null]|
    |  null|
    +------+
    ```
    
    This pr added the NULL-check expressions in Bean serializer along with the serializer of Scala's product types.
    
    ## How was this patch tested?
    Added tests in `JavaDatasetSuite`.


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

    $ git pull https://github.com/maropu/spark SPARK-19980

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

    https://github.com/apache/spark/pull/17347.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 #17347
    
----
commit 093b4e3baecf8a92b9e1218ae1b39b76120a826b
Author: Takeshi Yamamuro <ya...@apache.org>
Date:   2017-03-19T11:03:01Z

    Add null checks in Bean serializer

----


---
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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    **[Test build #74821 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74821/testReport)** for PR 17347 at commit [`093b4e3`](https://github.com/apache/spark/commit/093b4e3baecf8a92b9e1218ae1b39b76120a826b).


---
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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    can you send a new PR for branch 2.1? thanks!


---
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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    thanks, merging 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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

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


---
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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    @cloud-fan Could you check this? Thanks!


---
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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    **[Test build #74821 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74821/testReport)** for PR 17347 at commit [`093b4e3`](https://github.com/apache/spark/commit/093b4e3baecf8a92b9e1218ae1b39b76120a826b).
     * This patch **fails Scala style 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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    Merged build finished. Test FAILed.


---
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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    okay!


---
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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serial...

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

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


---
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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    **[Test build #74822 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74822/testReport)** for PR 17347 at commit [`77458a0`](https://github.com/apache/spark/commit/77458a07e068b7091fd7bdedeaf9fb3e460c83e1).
     * 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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/74822/
    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 #17347: [SPARK-19980][SQL] Add NULL checks in Bean serializer

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

    https://github.com/apache/spark/pull/17347
  
    **[Test build #74822 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74822/testReport)** for PR 17347 at commit [`77458a0`](https://github.com/apache/spark/commit/77458a07e068b7091fd7bdedeaf9fb3e460c83e1).


---
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