You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by yestinchen <gi...@git.apache.org> on 2017/08/04 09:34:05 UTC

[GitHub] flink pull request #4479: [FLINK-7309][hotfix] fix NullPointerException when...

GitHub user yestinchen opened a pull request:

    https://github.com/apache/flink/pull/4479

    [FLINK-7309][hotfix] fix NullPointerException when selecting null fields

    ## What is the purpose of the change
    
    This pull request addresses FLINK-7309, adds null check before applying unboxing on input fields.
    
    ## Brief change log
    
    - Add null check before applying unboxing on input fields.
    
    ## Verifying this change
    
    This change added tests and can be verified as follows:
     - Added test case: select null field from a Timestamp type field.
    
    ## Does this pull request potentially affect one of the following parts:
    
      - Dependencies (does it add or upgrade a dependency): (no)
      - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
      - The serializers: (no)
      - The runtime per-record code paths (performance sensitive): (no)
      - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)
    
    ## Documentation
    
      - Does this pull request introduce a new feature? (no)
      - If yes, how is the feature documented? (not applicable)
    


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

    $ git pull https://github.com/yestinchen/flink FLINK-7309

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

    https://github.com/apache/flink/pull/4479.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 #4479
    
----
commit 7cbbd13b723df11e72ccb115b5266104b0b01183
Author: Yestin <87...@qq.com>
Date:   2017-08-04T09:21:03Z

    [FLINK-7309][hotfix] fix NullPointerException when selecting null fields.

----


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

[GitHub] flink pull request #4479: [FLINK-7309][hotfix] fix NullPointerException when...

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

    https://github.com/apache/flink/pull/4479#discussion_r132703597
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala ---
    @@ -1181,8 +1188,12 @@ abstract class CodeGenerator(
     
         val wrappedCode = if (nullCheck && !isReference(fieldType)) {
           s"""
    -        |$tmpTypeTerm $tmpTerm = $unboxedFieldCode;
    -        |boolean $nullTerm = $tmpTerm == null;
    +        |$tmpTypeTerm $tmpTerm = $initValue;
    --- End diff --
    
    Please fix this without `initValue`.


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

[GitHub] flink pull request #4479: [FLINK-7309][hotfix] fix NullPointerException when...

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

    https://github.com/apache/flink/pull/4479#discussion_r132689501
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala ---
    @@ -1193,12 +1204,18 @@ abstract class CodeGenerator(
             |""".stripMargin
         } else if (nullCheck) {
           s"""
    -        |$resultTypeTerm $resultTerm = $unboxedFieldCode;
    +        |$resultTypeTerm $resultTerm = $initValue;
             |boolean $nullTerm = $fieldTerm == null;
    +        |if (!$nullTerm){
    +        |  $resultTerm = $unboxedFieldCode;
    +        |}
             |""".stripMargin
         } else {
           s"""
    -        |$resultTypeTerm $resultTerm = $unboxedFieldCode;
    +        |$resultTypeTerm $resultTerm = $initValue;
    --- End diff --
    
    We should not need a null check in this branch. This code is only generated if `nullCheck == false`.


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

[GitHub] flink pull request #4479: [FLINK-7309][hotfix] fix NullPointerException when...

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

    https://github.com/apache/flink/pull/4479#discussion_r132691900
  
    --- Diff: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/stream/sql/SqlITCase.scala ---
    @@ -314,5 +314,34 @@ class SqlITCase extends StreamingWithStateTestBase {
         assertEquals(expected.sorted, StreamITCase.testResults.sorted)
       }
     
    +  @Test
    +  def testSelectWithNullTimestamp(): Unit = {
    --- End diff --
    
    This bug should not be tested with an expensive ITCase. Please add one (or more) tests to `TemporalTypesTest` which is a unit test.


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

[GitHub] flink pull request #4479: [FLINK-7309][hotfix] fix NullPointerException when...

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

    https://github.com/apache/flink/pull/4479#discussion_r132703400
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala ---
    @@ -1193,12 +1204,18 @@ abstract class CodeGenerator(
             |""".stripMargin
         } else if (nullCheck) {
           s"""
    -        |$resultTypeTerm $resultTerm = $unboxedFieldCode;
    --- End diff --
    
    I fixed this case in PR #4488 as well which will be merged soon.


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

[GitHub] flink pull request #4479: [FLINK-7309][hotfix] fix NullPointerException when...

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

    https://github.com/apache/flink/pull/4479#discussion_r132690201
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala ---
    @@ -1172,6 +1172,13 @@ abstract class CodeGenerator(
         val resultTypeTerm = primitiveTypeTermForTypeInfo(fieldType)
         val defaultValue = primitiveDefaultValue(fieldType)
     
    +    // the initial value for result.
    +    val initValue = fieldType match {
    --- End diff --
    
    I had to fix the same issue for FLINK-7337 in PR #4488: https://github.com/apache/flink/pull/4488/files#diff-e05ff53adcc1407715fe09572ee092e0L1196
    
    I don't think we need this `initValue`. Especially, we should not introduce a special case for `String`. The problem with `String` was a buggy implementation of `concat` that did not respect the `isNull` field but relied on `resultTerm == null`. I fix this issue in my PR so, we can avoid the special case for `String` here.



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

[GitHub] flink issue #4479: [FLINK-7309][hotfix] fix NullPointerException when select...

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

    https://github.com/apache/flink/pull/4479
  
    Thanks for the PR @yestinchen.
    
    Will merge 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.
---

[GitHub] flink pull request #4479: [FLINK-7309][hotfix] fix NullPointerException when...

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

    https://github.com/apache/flink/pull/4479


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