[ https://issues.apache.org/jira/browse/FLINK-7309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16114166#comment-16114166 ]
ASF GitHub Bot commented on FLINK-7309: --------------------------------------- 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 <873915...@qq.com> Date: 2017-08-04T09:21:03Z [FLINK-7309][hotfix] fix NullPointerException when selecting null fields. ---- > NullPointerException in CodeGenUtils.timePointToInternalCode() generated code > ----------------------------------------------------------------------------- > > Key: FLINK-7309 > URL: https://issues.apache.org/jira/browse/FLINK-7309 > Project: Flink > Issue Type: Bug > Components: Local Runtime, Table API & SQL > Affects Versions: 1.3.1 > Reporter: Liangliang Chen > Priority: Critical > > The code generated by CodeGenUtils.timePointToInternalCode() will cause a > NullPointerException when SQL table field type is `TIMESTAMP` and the field > value is `null`. > Example for reproduce: > {code} > object StreamSQLExample { > def main(args: Array[String]): Unit = { > val env = StreamExecutionEnvironment.getExecutionEnvironment > val tEnv = TableEnvironment.getTableEnvironment(env) > // null field value > val orderA: DataStream[Order] = env.fromCollection(Seq( > Order(null, "beer", 3))) > > tEnv.registerDataStream("OrderA", orderA, 'ts, 'product, 'amount) > val result = tEnv.sql("SELECT * FROM OrderA") > result.toAppendStream[Order].print() > > env.execute() > } > case class Order(ts: Timestamp, product: String, amount: Int) > } > {code} > In the above example, timePointToInternalCode() will generated some > statements like this: > {code} > ... > long result$1 = > org.apache.calcite.runtime.SqlFunctions.toLong((java.sql.Timestamp) in1.ts()); > boolean isNull$2 = (java.sql.Timestamp) in1.ts() == null; > ... > {code} > so, the NPE will happen when in1.ts() is null. -- This message was sent by Atlassian JIRA (v6.4.14#64029)