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/21 08:15:44 UTC

[GitHub] spark pull request #17372: [SPARK-19980][SQL][BACKPORT-2.1] Add NULL checks ...

GitHub user maropu opened a pull request:

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

    [SPARK-19980][SQL][BACKPORT-2.1] 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-BACKPORT2.1

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

    https://github.com/apache/spark/pull/17372.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 #17372
    
----
commit 89305b6e4d625b62a160bb598ca9037f9ef45068
Author: Takeshi Yamamuro <ya...@apache.org>
Date:   2017-03-21T08:08:13Z

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

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

    https://github.com/apache/spark/pull/17372
  
    @cloud-fan could you check this?


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

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

    https://github.com/apache/spark/pull/17372
  
    thanks, merging to branch 2.1


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

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

    https://github.com/apache/spark/pull/17372
  
    **[Test build #74961 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74961/testReport)** for PR 17372 at commit [`89305b6`](https://github.com/apache/spark/commit/89305b6e4d625b62a160bb598ca9037f9ef45068).
     * This patch **fails to build**.
     * 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 #17372: [SPARK-19980][SQL][BACKPORT-2.1] Add NULL checks in Bean...

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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


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

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

    https://github.com/apache/spark/pull/17372
  
    **[Test build #74961 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74961/testReport)** for PR 17372 at commit [`89305b6`](https://github.com/apache/spark/commit/89305b6e4d625b62a160bb598ca9037f9ef45068).


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